develooper Front page | perl.perl5.porters | Postings from May 2003

$x = $empty_hash{$undef_val} doesn't give a warning

Thread Next
Dave Mitchell
May 16, 2003 16:27
$x = $empty_hash{$undef_val} doesn't give a warning
Message ID:
In the following,

    @a2 = (1);
    %h2 = (1,1);
    $x = $a1[$X];       # Use of uninitialized value in array element
    $x = $a2[$X];       # Use of uninitialized value in array element
    $x = $h1{$X};       # silent
    $x = $h2{$X};       # Use of uninitialized value in hash element

you get lots of warnings related to $X having an uninitialised value,
except in the case of an empty/undefined hash. Note that an empty/undef
array doesn't suffer the same fate.

Should this be construed as a bug or a feature?

(present from at least 5_003_22 through to bleedperl)


"There's something wrong with our bloody ships today, Chatfield."
Admiral Beatty at the Battle of Jutland, 31st May 1916.

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