Well, the obvious problem is that you are getting an array reference back from %player_info. The [] brackets construct a reference to an array. So when you do:

$player_info{$1}= [ qw($value1 $value2) ]; (my $nkey, my @nvalue) = each %player_info

You are actually putting a reference into $player{$1} info and then retreiving it into @nvalue. @nvalue then has one element, the arrayref i.e. $nvalue[0]=ARRAY(0xblahblahblah).

To do this right, you need to catch the reference like this:

(my $nkey, my $nvalue_ref) = each %player_info ; my @nvalue = @{$nvalue};

However that won't make a difference, because you aren't actually putting anything into your array - you never put any values into $value1, $value2! Are you using strict?

Also, your parsing routine is a little complicated. Rather than doing the passes, strip the header before the loop, then do a =~ /(stuff)\s(more stuff)\s(stuff2)\n(even more stuff)....\n/

Also this:

[ qw($value1 $value2) ];

should be:

[ $value1, $value2 ];

Also (this is a personal style choice, but) this is can be done differently (TIMTOWTDI)

(my $nkey, my $nvalue_ref) my ($nkey, $nvalue_ref)

HTH

Update: Typical. Two people beat me. I must type slow, or think slow :) Corrected my reasoning on the qw().

____________________
Jeremy
I didn't believe in evil until I dated it.


In reply to Re: hash of arrays -- Im missing something by jepri
in thread hash of arrays -- Im missing something by snafu

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.