bogbert has asked for the wisdom of the Perl Monks concerning the following question:
I noticed that if I'm using several uninitialized variables in a string, and if at least one of those variables is a hash, then the name of the hash only appears in the warnings if it's the first uninitialized variable of the string.
For exampleprints the following warnings:#!/usr/bin/perl use warnings; my (%a, %b, $c); my $x = "$a{'foo'} $b{'bar'} $c"
Use of uninitialized value $a{"foo"} in concatenation (.) or string at + main.pl line 5. Use of uninitialized value in concatenation (.) or string at main.pl l +ine 5. Use of uninitialized value $c in concatenation (.) or string at main.p +l line 5.
You'll notice that the name of the variables $a{"foo"} and $c appear in the 1st and 3rd warnings, but the name of $b{"bar"} doesn't appear in the 2nd warning.
Is there a good reason for that or is it a defect ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable name missing in warning
by bigj (Monk) on Apr 02, 2014 at 16:48 UTC | |
by LanX (Saint) on Apr 02, 2014 at 21:36 UTC | |
by tye (Sage) on Apr 03, 2014 at 06:24 UTC | |
by LanX (Saint) on Apr 03, 2014 at 10:02 UTC | |
by tye (Sage) on Apr 03, 2014 at 20:59 UTC | |
| |
by Anonymous Monk on Apr 02, 2014 at 17:23 UTC | |
|
Re: Variable name missing in warning
by toolic (Bishop) on Apr 02, 2014 at 16:33 UTC | |
by Your Mother (Archbishop) on Apr 02, 2014 at 16:40 UTC | |
by LanX (Saint) on Apr 02, 2014 at 16:44 UTC | |
by bogbert (Initiate) on Apr 02, 2014 at 16:39 UTC |