[Melbourne-pm] Postfix conditionals and creating lexicals

Sam Watkins sam at nipl.net
Thu Jul 12 17:04:38 PDT 2012

Robert Norris wrote:
> Seems a bit hit-and-miss (actually mostly miss):
>     robn at pyro:~$ perl -Mwarnings -Mstrict -E 'my $x if 0'
>     Deprecated use of my() in false conditional at -e line 1.
>     robn at pyro:~$ perl -Mwarnings -Mstrict -E 'my $x if 1'
>     robn at pyro:~$ perl -Mwarnings -Mstrict -E 'my $x if undef'
>     robn at pyro:~$ foo=0 perl -Mwarnings -Mstrict -E 'my $x if $ENV{foo}'
>     robn at pyro:~$ foo=1 perl -Mwarnings -Mstrict -E 'my $x if $ENV{foo}'
>     robn at pyro:~$ perl -v

looks like targetting the specific idiom:
  my $foo ... if 0

should warn about any
  my $foo ... if ...

> So while we can argue about whether or not its a bug

unintended dis-recommended 'features' are bugs, categorically

> If I get around to it I'll open a bug report, even if its just asking
> for better warnings. I doubt I'll have time to work up a patch myself.

If can detect the pattern with 'use warnings', I guess not too hard
to make it a syntax error in the core.  Maybe don't want to break
existing abuse of it, so leave it in use warnings / use strict.


More information about the Melbourne-pm mailing list