Bryan R Harris wrote:
Bryan Harris wrote:
John W. Krahn wrote:
Bryan Harris wrote:
... but by modifying $_ I was clobbering $_ elsewhere in the larger
program!
Yes because $_ is a special global variable. This effect is called
"action at a distance" which is why it is better to use named lexically
scoped variables instead of $_.
I have the Perl Bookshelf on CD (and perldoc, obviously) -- where can I read
more about this?
perldoc perlvar
http://shoebox.net/articles/perl-warts.html
http://en.wikipedia.org/wiki/Action_at_a_distance_(computer_science)
Great info, thanks.
Curiously, perlvar seems to recommend localizing $_ with "local", but I
thought I read somewhere to never use local and only use my. I still don't
understand how those two are different.
local() only works on variables that are in the symbol table, in other
words package variables. All variables that are a single puntuation
character are package variables and some are global and effect all
packages. local() does not create a variable it just masks the current
value of a variable within the current scope.
my() creates variables that are not in the symbol table and are visible
only within the current block or file.
Oddly, perl won't let me do "my ($_) = shift;", so I'm stuck having to use
another variable.
Perl 5.10 *will* let you do "my $_".
Why is perl on OS X still at 5.8.8? It's free, right? why wouldn't Apple
include the latest one? (I know this isn't an Apple list, just wondering if
anyone knows.)
Perl 5.10 is still at the .0 stage (5.10.0) and a lot of people like to
wait until software has progressed past the .0 phase.
Makes sense. What happened to Perl 5.9?
As of Perl 5.6 the odd numbered versions (5.7 and 5.9) are for
development only.
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/