Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • Are you sure you want splitdir/catfile and not splitpath/catpath?

    • To be honest, I use those so seldom, I never really paid attention to the difference.

      Making both of those changes results in a lot of uninit value warnings from catpath, even though the tests pass :/

      sub catpath {
          my ($self,$volume,$directory,$file) = @_;

          # this gives me uninit warnings
          if ( $directory ne ''                &&
               $file ne ''             

      • Huh, what are you passing to it?

        • Er, um, really wish I had read the documentation rather than doing a quick %s/one/fortheother/. *blush*.

          • Heh. That’s what I meant by “Unix blinders” – and not pejoratively, as I used to wear them for the longest time myself. Unix is so nicely simple: no volumes, no distinct namespaces for file and directory names, just one uniform hierarchy… after a while one forgets the bizarre things that exist elsewhere.

    • I think it's actually spelled:

      use File::Basename;
  • 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:


      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.