On Friday 13 July 2007 10:33:59 am Matt Lawrence wrote:
> Perrin Harkins wrote:
> > my $vote = $foo if ($bar); # <--- bad!
>
> What's wrong with that? I find it a lot more readable than
>
> my $vote;
> if ($bar) {
> $vote = $foo;
> }
>
Only the fact that it makes perl do Bad Things :)
"my $foo if CONDITION" triggers a bug that lets perl violate the expectation
for the duration of a lexical variable. If the CONDITION is false, $foo
doesn't get undef. It gets a value that's completely unexpected -- unless
you're using it for hack value, but don't do that either :)
Andrew
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/