in reply to Wierd error message
my @array=qw/foo bar/; $array[3] = "baz"; foo1( @array ); # $array[2] is undefined
One way to avoid the warning would be:
(I took the liberty of eliminating unnecessary variables, and localizing the scope of needed variables a little more tightly.)for my $param (grep {defined} @_) { for my $val ( split /\n/, $param ) { print "The value is: $val\n"; # or whatever you want to do } }
The other methods suggested above would also work, I expect. There might be reasons for preferring one approach over the other, depending on the rest of your application.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Wierd error message
by herby1620 (Monk) on Aug 16, 2006 at 22:13 UTC |