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

Re: bug: my creates a c like function static variable!

Thread Previous | Thread Next
From:
___cliff rayman___
Date:
September 23, 2000 09:46
Subject:
Re: bug: my creates a c like function static variable!
Message ID:
39CCDE50.6D6D19C@spamless.genwax.com
you can find discussion related to this issue here:

http://www.perl.com/pub/2000/05/p5pdigest/THISWEEK-20000521.html#my_x_if_0;_Trick

by the way, this is considered a features, not a bug!  :-)

--
___cliff rayman___cliff@genwax.com___http://www.genwax.com/
Ajai Shankar wrote:

> 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 Previous | 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