in reply to Trying to capture a value from a list of values
Here's how I would like to see your script: ( YMMV )
Save the 'printf' for formatted printing, so that it becomes obvious upon review. And if you had used structures, you would have known that '$lnxsrvr' is undefined when you exit the 'foreach' loop. Perl allows for generous whitespace, so use whitespace to help you follow the flow of your work. Originally when I looked at your code, I didn't notice the closure to the 'foreach' loop.use strict; . . . my @mylnxsrvrs = split(',', $myhash{SBLLNXSRVRHOSTS}); foreach my $something ( @mylnxsrvrs ) { my $lnxsrvr = "$something"; print "$something $lnxsrvr\n\n"; } print "$lnxsrvr\n"; ## Undefined now! print "@mylnxsrvrs";
But I suspect your problem is in the 'split' and without seeing what '$myhash{SBLLNXSRVRHOSTS})' looks like, we can't help solve your problem.
Regards...Ed
"Well done is better than well said." - Benjamin Franklin
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Trying to capture a value from a list of values
by parthodas (Acolyte) on Sep 02, 2015 at 11:36 UTC | |
by tangent (Parson) on Sep 02, 2015 at 11:45 UTC | |
by parthodas (Acolyte) on Sep 02, 2015 at 12:05 UTC |
In Section
Seekers of Perl Wisdom