I have a dat file looking like this:
__________
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
__________
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