in reply to Re^2: Announcing Perl-Critic-0.14
in thread Announcing Perl-Critic-0.14
Please forgive my ignorance, but what's wrong with it? $foo ends up as 1 when $bar is true and is undefined when $bar is false. Just as I expect it to be. (Active Perl 5.8.7)Wrong. This piece of code is one of the weird things in perl, in this case, something that is sometimes used as a dirty trick, to create a static variable.
Result:#!/usr/bin/perl -lw print $]; for (1 .. 5) { my $i = 123 if $bar; print ++$i; }
Name "main::bar" used only once: possible typo at test.pl line 4. 5.008003 1 2 3 4 5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Announcing Perl-Critic-0.14
by holli (Abbot) on Jan 30, 2006 at 17:26 UTC | |
by Aristotle (Chancellor) on Jan 30, 2006 at 17:59 UTC | |
by diotalevi (Canon) on Jan 30, 2006 at 21:08 UTC | |
by ysth (Canon) on Jan 30, 2006 at 18:43 UTC |