in reply to Wierd error message

Here is one way to generate that sort of warning message (there are many other ways):
my @array=qw/foo bar/; $array[3] = "baz"; foo1( @array ); # $array[2] is undefined

One way to avoid the warning would be:

for my $param (grep {defined} @_) { for my $val ( split /\n/, $param ) { print "The value is: $val\n"; # or whatever you want to do } }
(I took the liberty of eliminating unnecessary variables, and localizing the scope of needed variables a little more tightly.)

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
    Reply most helpful. I was able to make the proper tests, and incorporate the detection of "undefined" stuff in my code.

    Sorry if the example isn't that good. I tried to extract the pertinant stuff for the example. The intended application is a "tie" method for output (prints). It replaces the output method to stdout, and adds the time, and module/line as a prefix. It seems to work quite well, as we've put it in a bunch of scripts here. Efficient? I don't know, it does the job, and really isn't called that much. I suspect that being my first module, it refelcts my background ("...you can program in Fortran in any language.").