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
In reply to Re^3: Announcing Perl-Critic-0.14
by bart
in thread Announcing Perl-Critic-0.14
by jthalhammer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |