in reply to Re: static-like persistence of my variable due to trailing conditional
in thread static-like persistence of my variable due to trailing conditional
But a global $foo isn't getting set -- otherwise "-w/use strict" would complain.
I honestly have no idea what in the semantic rules of Perl describes the behavior you are seeing. Why this compiles, and does what it does without complianing is beyond me. I would expect it to complain the same way this does...
#!/usr/bin/perl -w use strict; sub mycode { my $var = $_[0]; my $foo = "blah" if $var; print "foo is $foo\n" if $foo; $bar ||= "BAR"; } mycode("test"); mycode(); mycode(); mycode();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: static-like persistence of my variable due to trailing conditional
by jsprat (Curate) on Jun 29, 2002 at 22:29 UTC | |
by meonkeys (Chaplain) on Jun 29, 2002 at 22:52 UTC | |
by jsprat (Curate) on Jun 29, 2002 at 23:32 UTC | |
by Aristotle (Chancellor) on Jun 30, 2002 at 17:35 UTC |