http://qs321.pair.com?node_id=703193

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(@_);