Blessings upon ye monks!

I've recently run across this error message:

Use of uninitialized value in join or string at /usr/lib64/perl5/5.8.8 +/x86_64-linux-thread-multi/File/Spec/Unix.pm line 81

Which wouldn't be a big deal if I were actually using File::Spec in my own code.

Long story short, I found my own bug and I've written a patch for File::Spec::Unix that makes it generate a useful error instead of the one above.

My solution was to use Carp and cluck if conditions would cause the situation above.

So, my request from ye monks is any feedback on my solution and patch before I mail it off the author.

Thanks!
--Pileofrogs

UPDATE: I've changed the patch. The old version clucked if there were no args, the new version clucks if @_ contains an undef. IE something that exists but is not defined, EG catdir('/home',undef,'wibble')

--- lib.old/File/Spec/Unix.pm 2008-02-11 19:43:20.000000000 -0800 +++ lib/File/Spec/Unix.pm 2008-08-08 16:15:55.000000000 -0700 @@ -1,6 +1,7 @@ package File::Spec::Unix; use strict; +use Carp qw(cluck); use vars qw($VERSION); $VERSION = '3.2701'; @@ -78,7 +79,12 @@ sub catdir { my $self = shift; - + for ( @_ ) { + if ( !defined($_) ) { + cluck "Undefined arg passed to catdir"; + last; + } + } $self->canonpath(join('/', @_, '')); # '' because need a trailing + '/' } @@ -91,6 +97,11 @@ sub catfile { my $self = shift; + for ( @_ ) { + if ( !defined($_) ) { + cluck "Undefined arg passed to catfile"; + last; + } my $file = $self->canonpath(pop @_); return $file unless @_; my $dir = $self->catdir(@_);

In reply to File::Spec patch by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.