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

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

Thread Next
From:
Dave Mitchell
Date:
May 16, 2003 16:27
Subject:
$x = $empty_hash{$undef_val} doesn't give a warning
Message ID:
20030516232815.GA16119@fdgroup.com
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)

Dave.



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

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