develooper Front page | perl.perl5.porters | Postings from March 2000

Out of the frying pan into the fire

From:
Wolfgang Laun
Date:
March 6, 2000 23:40
Subject:
Out of the frying pan into the fire
Message ID:
38C4B236.BCB48636@alcatel.at
This is the frying pan:

   $ perl -we 'print "a=$a\n";'
   Use of uninitialized value at -e line 1.
   a=

This is the fire:

   $ perl -we '$a ||= ""; print "a=$a\n";'
   a=

Why? Because!

   $perl -e '$a="0"; $a ||= ""; print "a=$a\n";'
   a=

Moral of the story: When trying to avoid -w(arnings) against
uninitialized variables you cannot simply insert $v ||= ''; statements.

Regards,
-Wolfgang




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