I am reading in a tab delimited file to a hash of arrays as follows:
open (TESTFILE, "filename"
;
while (<TESTFILE>) {
chomp;
($cashflows{field0}[$rowcount],
$cashflows{field1}[$rowcount],
$cashflows{field2}[$rowcount]) =
split(/\t/, $_);
$rowcount ++
}
I then want to sort the hash of arrays by field 2. For example the file contains
1234 text ID25
1765 text ID16
8765 text ID19
After sorting I would like to print out the hash of arrays as:
1765 text ID16
8765 text ID19
1234 text ID25
Can anyone advise on the sort technique. I have tried various approaches but cannot get this to work. Many thanks.
open (TESTFILE, "filename"
while (<TESTFILE>) {
chomp;
($cashflows{field0}[$rowcount],
$cashflows{field1}[$rowcount],
$cashflows{field2}[$rowcount]) =
split(/\t/, $_);
$rowcount ++
}
I then want to sort the hash of arrays by field 2. For example the file contains
1234 text ID25
1765 text ID16
8765 text ID19
After sorting I would like to print out the hash of arrays as:
1765 text ID16
8765 text ID19
1234 text ID25
Can anyone advise on the sort technique. I have tried various approaches but cannot get this to work. Many thanks.