develooper Front page | perl.perl5.porters | Postings from February 2021

Warning about "$foo=$bar if $baz"

Thread Next
Josef Wolf
February 12, 2021 12:28
Warning about "$foo=$bar if $baz"
Message ID:

in "perldoc perlsyn", there is this warning:

  NOTE: The behaviour of a "my", "state", or "our" modified with a statement
  modifier conditional or loop construct (for example, "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.

Unfortunately "use strict; use warnings;" won't enable warnings about this

I wonder if there is some way to cause the perl interpreter to emit warnings
when such constructs are used.

Any hints?

Josef Wolf

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About