hikarihikari has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I am new to perl and I would like to ask how would I loop in a hash table while getting the value of each row using and store that value in an array.

Update

my %hash; open (INPUT, "file") or die "Can't open file: $!"; my $records = <INPUT>; chomp($records); while (<INPUT>){ my @arr = split (/\ /, $_); my ($key, $value) = ($arr[1], $arr[0]); $hash{$key} = $value; print "$key\t$value\n"; }
My code goes like that and I checked it it's working since I got to store the values of the file in a hash table. My next target is to loop within my hash and get each value and will use its value in listing a file. Thank you very much!

Replies are listed 'Best First'.
Re: Looping in hash table and get each row value
by hdb (Monsignor) on Jun 06, 2013 at 07:32 UTC
      hi thank you for this but what I mean is I want to get EACH row value in the hash table not just store all its value in an array..

        Can you specify what you mean by "row value in the hash table" ? Some example?

Re: Looping in hash table and get each row value
by kcott (Archbishop) on Jun 06, 2013 at 07:59 UTC

    G'day hikarihikari,

    Welcome to the monastery.

    The Perl Data Structures Cookbook may provide you with an answer. If not, please provide a sample of your data structure: it sounds like you're possibly working with a hash of arrays but that's just a guess. Also, an idea of the output you're expecting would be useful. Any code you've already attempted may prove helpful. Take a look at "How do I post a question effectively?" to get an idea of the type of information that's appropriate.

    -- Ken