in reply to Re: "$_" vs. $_
in thread "$_" vs. $_
my $bar = "world"; sub foo { while (@_) { $bar = shift; $params->{$bar} = shift; } print "$_: $params->{$_}\n", for keys %$params; } foo ( hello => $bar );
We're used to seeing things like this because we declare the variables and make that mental connection to it as "global variable", which you can see getting changed inside foo(). For some reason, that doesn't strike me as so obvious when using $_, since I sort of think of it more as an abstract placeholder for short-term uses of values when I don't want to make a whole new variable.
anyway, thanks for the clarification
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: "$_" vs. $_
by blazar (Canon) on Apr 08, 2007 at 11:09 UTC |