Bryan Harris wrote:

Doesn't that try to re-localize (?) the @array variable every time
through the loop?  i.e. doesn't it re-run the my() function every time
through the loop?  For some reason I thought that was a no-no.

my() happens when the code is compiled so it is *not* re-run every time
through the loop.  The assignment happens when the code is run so it is
re-run every time.

Out of curiosity, how did you know that? I've mostly been through the camel and llama books, but somehow I missed that...

perldoc perlsub

[ snip ]

    A "my" has both a compile-time and a run-time effect.  At compile
    time, the compiler takes notice of it.  The principal usefulness of
    this is to quiet "use strict ’vars’", but it is also essential for
    generation of closures as detailed in perlref.  Actual
    initialization is delayed until run time, though, so it gets
    executed at the appropriate time, such as each time through a loop,
    for example.



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/


Reply via email to