Molybdenum Monks,

Uh, it's Twilight Zone time here. For three years this has been working fine:

foreach $group_id (keys %data) { @temp = sort keys %{ $data{$group_id} }; $my_hoa{$group_id}{'ordered'} = [ @temp ]; } foreach $group_id (sort keys %my_hoa) { for $i (0 .. $#{ @{ $my_hoa{$group_id}{'ordered'} } }) { # output some stuff; } }
Then a few days ago the loop stopped working. After adding
print "<p>array length = ".$#{ @{ $pubs{$lang_group_id}{'pub_alpha_ord +er'} } }."<p>\n";
at the beginning of the output loop, it became clear that

$#{ @{ $pubs{$lang_group_id}{'pub_alpha_order'} } }

was coming back as -1.

Weird, but ok, so just for argument's sake I changed it to

$#{ $pubs{$lang_group_id}{'pub_alpha_order'} }

And miracle of miracles, we're back in business. But, cue the Twilight Zone music, as I said, this has been working fine for years. Or has it?

Two possibilities - it never really worked, everyone just thinks they remember it working, or the server admins updated Perl and the new version refers to this kind of thing differently? So I'm inquiring about the second possiblity - did the way you refer to this change in a recent update of Perl? If not, we're checking the koolaid.

Thanks




Time flies like an arrow. Fruit flies like a banana.

In reply to Something changed in how to refer to length of hash of arrays? by punch_card_don

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.