in reply to map and undef - odd behaviour with an array of arrays
Running:
produces:use Data::Dumper; $x[0]=[0];map{undef $_}(@x);print "still defined\n" if defined @x; print Dumper(\@x);
I trust that clarifies what is going on. That is, your array contains a single element with the value undef. Note that an array containing a single element with an undef value is not undef, not even false in scalar context. To be false in scalar context, the array needs to be empty.defined(@array) is deprecated at undef1.pl line 2. (Maybe you should just omit the defined()?) still defined $VAR1 = [ undef ];
Oh, and please heed the deprecated warning and replace "if defined @x" with simply "if @x" (see defined for why).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map and undef - odd behaviour with an array of arrays
by Melly (Chaplain) on Dec 22, 2012 at 08:45 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 22, 2012 at 08:53 UTC |