Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
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.
$ perl -e '
for (1..5) {
my $count;
$count += 1;
print $count;
last if $count == 3;
}
print "\n";
'
11111
I don't understand what you are trying to demonstrate with that code?
That my() also happens at run-time,
And how does your code demonstrate that?
I believe it's self-speaking, provided that you realize what the output
would have been without the my() statement
Then it wouldn't demonstrate that my() happens at run-time because there
would be no my() at all.
(or with the my() statement placed before the loop).
Then the variable would be in file scope and it would still be declared
at compile-time.
What's your point?
I am trying to understand what point you are trying to make.
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/