in reply to my $cache = undef if undef;
Sorry to all the previous commenters, but they're all wrong. Tanktalus is close with his second bullet point, but then he says it doesn't work, which is wrong.
That piece of code makes a pseudostatic variable, ie one that persists across calls to the function.
This is known as the my $foo if 0 trick. The if undef in your code is the same thing painted green: a false condition.
This shouldn't be used in production code. Tanktalus' suggestion of using a closed-off scope is what you should replace it with.
Makeshifts last the longest.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: my $cache = undef if undef;
by borisz (Canon) on Jan 26, 2005 at 18:33 UTC | |
Re^2: my $cache = undef if undef;
by Tanktalus (Canon) on Jan 26, 2005 at 17:38 UTC | |
by chromatic (Archbishop) on Jan 26, 2005 at 17:55 UTC | |
by Aristotle (Chancellor) on Jan 26, 2005 at 17:48 UTC | |
by ysth (Canon) on Jan 27, 2005 at 06:32 UTC | |
by Aristotle (Chancellor) on Jan 27, 2005 at 17:28 UTC |
In Section
Seekers of Perl Wisdom