import-bot (20211) [Avatar] Offline
#1
[Originally posted by dudeyes]

I'm having a problem understanding the workings of my() and local(). On pgs.
125-126, you gave an example of

my $foo = 'outer;
$_ = 'global';
{
local($_) = 'localized';
my $foo = 'inner';
show_me();
}
sub show_me
{
print "$_: $foo
";
}

you mentioned that show_me always runs where it is DEFINED in the file, so in
this case its defined in the "outer" block, so using that, I can understand
why it printed 'outer' for $foo, but not 'global' fo r $_ . Does this mean a
variable modified by the local() function will have precedence over the
non-local variable of the same name? Otherwise, $_ should have printed global,
right? I'm I even close to understanding this?
Any help is much appreciated.
BTW , looking over how you run this msg board, this is a much better way to
learn Perl than taking a class. I had the option of enrolling in a semester
long class or buying your book - I'm glad I chose your book. You are much more
patient and responsive than 90% of the professors I've had in college so far,
and your right up there with the the other 10% best I've had.