guisilva has asked for the wisdom of the Perl Monks concerning the following question:
Running totals: Question 1: 60 Question 2: 123 Question 3: 99 Averages: Question 1: 4.6 Question 2: 9.5 Question 3: 7.6
I have a code to store the Running totals into a hash, such as the following:
my %hash; my $key; my $value; open(ANSWERTALLY, "answertally.dat"); while(ANSWERTALLY n) { ($key, $value) = split(/\s=\s/); chomp($value); $hash{$key} = $value; } close(ANSWERTALLY);
However, this code will try to read everything in the file. How can I tell it to skip the first line (RUNNING TOTALS), and stop executing when it encounters AVERAGES:??? I'm not too good with string manipulation or regular expressions.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading from middle of file
by davorg (Chancellor) on Aug 12, 2004 at 15:25 UTC | |
by guisilva (Initiate) on Aug 12, 2004 at 16:36 UTC | |
by davorg (Chancellor) on Aug 12, 2004 at 16:50 UTC | |
by Random_Walk (Prior) on Aug 12, 2004 at 16:55 UTC | |
|
Re: reading from middle of file
by Dietz (Curate) on Aug 12, 2004 at 16:36 UTC |