[Catalyst] TT2 + CP::Authentication + DBIC gotcha

Perrin Harkins perrin at elem.com
Fri Jul 13 18:27:47 GMT 2007


On 7/13/07, Matt Lawrence <matt.lawrence at ymogen.net> wrote:
> I can't replicate this behaviour. As far as I can tell, the postfix if
> is identical to the block if I wrote above.
>
>
> perl -Mstrict -wle 'my $foo = 1 if 0; print defined $foo ? $foo : "undef"'
> undef
>
>
> Has the bug been fixed?

No.  Here's a quite from perlsyn:
NOTE: The behaviour of a "my" statement modified with a statement
modifier conditional or loop construct (e.g. "my $x if ...") is
undefined. The value of the "my" variable may be "undef", any
previously assigned value, or possibly anything else. Don't rely on
it. Future versions of perl might do something different from the
version of perl you try it out on. Here be dragons.

There is also a Perl::Critic policy to detect these:
http://search.cpan.org/~thaljef/Perl-Critic-1.06/lib/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm

- Perrin



More information about the Catalyst mailing list