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

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

Thread Next
From:
Josef Wolf
Date:
February 12, 2021 12:28
Subject:
Warning about "$foo=$bar if $baz"
Message ID:
20210212120949.GC29238@raven.inka.de
Hello,

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
construct.

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

Any hints?

-- 
Josef Wolf
jw@raven.inka.de

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About