Using formatted numbers has hash keys is not a good idea. The data is not in $hash{00} but in $hash{0}, as 00 is interpreted as a number and not as a string.

When in doubdt about your data try either the perl debugger (run perl -d) or Data::Dumper (or Data::Denter if you have it installed):

#!/bin/perl -w use strict; use Data::Dumper; my @foo = (0,1); my %hash; $hash{00} = "data"; $hash{"00"} = "the real one"; $hash{10} = "moredata"; print Dumper( %hash); print '$hash{0} is ', $hash{0} , "\n"; print '$hash{00} is ', $hash{00} , "\n"; print '$hash{$foo[0] . "0"} is ', $hash{$foo[0] . "0"}, "\n"; print '$hash{$foo[1] . "0"} is ', $hash{$foo[1] . "0"}, "\n"; print '$hash{10} is ', $hash{10} , "\n";

In reply to Re: Hash element that won't print. Perl Bug??? by mirod
in thread Hash element that won't print. Perl Bug??? by monkfish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.