On 11-06-03 11:37 AM, sono...@fannullone.us wrote:
I want to use "$name" in another loop just after this one, but when I do, I get
"Global symbol $name requires explicit package".
Could someone please point me in the right direction?
Certainly. The variable used in a foreach loop is independent of
anything outside the loop. Even if it's declared before the loop, it's
value is unavailable inside the loop:
#!/usr/bin/env perl
use strict;
use warnings;
my $name = 'forgotten';
for $name ( qw( fred barney wilma )){
print "\$name is $name\n";
}
print "\$name is $name\n";
__END__
Outside the loop, it becomes just another variable.
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/