in reply to Help with printing values from a hash of hashes

Replace

$data{$system}{$fields[$1]} = $fields[$2];

with

$data{$system}{$fields[0]} = $fields[1];

The $n variables are used to access data captured in regexes with capture brackets, not for indexing arrays.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Help with printing values from a hash of hashes
by xdg (Monsignor) on Mar 31, 2006 at 02:28 UTC

    As I mention below, I think the OP wants indexes 1 and 2 -- meaning the 2nd and 3rd element after splitting on ":".

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      Right. I just mentally translated first & second capture to first & second index, and didn't notice that the first field was repeated (in some cases and not quite in others), in the data.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.