in reply to seeking advise on average value problem
# We already have a filehandle open for reading. Read # file line by line, putting data into a hash table. # our %averages = (); while(<IN>) { # Pick out the "average" lines with a regular # expression using () round brackets to remember # the "average1 or 2" (in $1) and the value ($2). # next unless /^(average\d+):\s+(\d+\.\d+)$/; push @{$averages{$1}}, $2; }
you end up with a hash table with keys "average1" and "average2" and the values being a list of the relevant values so that doing
print $averages{average1}->[0], "\n"; print $averages{average2}->[1], "\n";
Would produce
3.2 5.0
I hope this helps.
Cheers,
JohnGG
|
|---|