Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • How about a method that returns the serialiser code as a string (with selectable package name), which can then be evaled by the test file for testing?

    • I don't want to embed a string of code. I'm doing a huge amount of that already to do code generation and it makes a lot of my code hard to follow, despite aggressive refactoring. If I keep these packages in real packages, I get the benefits of my t/00-load.t test:

      #!perl

      use Test::More;
      use File::Spec::Functions 'splitdir';
      use File::Find;

      sub path_to_module {
          my $path = shift;
          $path =~ s/\.pm\z//;
          my @components = splitdir($path);
          shift @components;

      • Put it in a SelfLoader module and add a method to pull out the source via the package’s DATA handle? That way you avoid all the path diddling gymnastics and it automatically works as a standalone module.