develooper Front page | perl.perl5.porters | Postings from September 2013

variable warnings

Thread Next
From:
H.Merijn Brand
Date:
September 24, 2013 06:20
Subject:
variable warnings
Message ID:
20130924081946.17532f3c@pc09.procura.nl
I've got used to the ultimately helpful warnings for *which* variable
is undefined:

$ perl -wE'say $x'
Name "main::x" used only once: possible typo at -e line 1.
Use of uninitialized value $x in say at -e line 1.
$ perl -wE'my $x; say $x'
Use of uninitialized value $x in say at -e line 1.

Would it be possible to extend that to containers in arrays and hashes?

$ perl -wE'my @x; say $x[1]'
Use of uninitialized value in say at -e line 1.
$ perl -wE'my %x; say $x{foo}'
Use of uninitialized value in say at -e line 1.

=>

$ perl -wE'my @x; say $x[1]'
Use of uninitialized value $x[1] in say at -e line 1.
$ perl -wE'my %x; say $x{foo}'
Use of uninitialized value $x{foo} in say at -e line 1.

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.19   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

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