[Melbourne-pm] Postfix conditionals and creating lexicals

Ben Hare benhare at gmail.com
Thu Jul 12 03:50:20 PDT 2012

This is a Perl bug IMO. You can see why this sort of thing can happen
due to Perl's shorthand way of writing things eg:

if ( $foo ) {
    my $bar = 1; # local scope variable to the conditional block

my $bar = 1 if $foo; # woops, no local scoping now

You wouldn't be able to write the latter in other languages such as
javascript. I actually thought ( without actually testing it ) that
the latter would be an error but it seems not! Again tho, you can see
why - Perl probably can't distinguish between the two cases. I think
basically the answer is it would be bad practice to code in the latter


PS: Hi Mat and Brendon!

On 12 July 2012 17:17, Mathew Robertson
<mathew.blair.robertson at gmail.com> wrote:
> -1...
> Even though I know it is a static, I would never use it that way... It
> strictly isn't documented as that, and causes my head to implode.
> On 12 July 2012 16:14, Sam Watkins <sam at nipl.net> wrote:
>> Mathew Robertson wrote:
>> > It is a static variable.
>> +1 almost useful, maybe a secret feature!
>> at least it doesn't (seem to) cause a SEGV
>> Sam
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm

Ben Hare
Professional Web Development Services
ABN: 22-48-55-71-887
Phone: +61-415-607-197
Web: http://www.benhare.com
Email: ben at benhare.com

More information about the Melbourne-pm mailing list