develooper Front page | perl.perl5.porters | Postings from September 2000

bug: my creates a c like function static variable!

Thread Next
From:
Ajai Shankar
Date:
September 22, 2000 18:43
Subject:
bug: my creates a c like function static variable!
Message ID:
004701c02509$08e48020$481898d8@ajaishankar
Hi

Why does this behave like a c function static variable?

use strict;

sub foo() {
 my $x if 0;
 print "\$x is $x and ref \$x is " , \$x , "\n";
 $x = 1 if !defined $x;
}

for(1..3) {
 foo
}


Thanks

ajai

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About