I'm a total newbie to Perl, but I've heard that it's great for parsing files, so I've thought of giving it a spin.
I have a text file that has the following sample info:
High school is used in some
parts of the world, particularly in
Scotland, North America and Oceania to
describe an institution that provides
all or part of secondary education.
The term "high school" originated in
Scotland with the world's oldest being
the Royal High School (Edinburgh) in
1505.
The Royal High School was used as a
model for the first public high school
in the United States, the English High
School founded in Boston,
Massachusetts, in 1821. The precise
stage of schooling provided by a high
school differs from country to
country, and may vary within the same
jurisdiction. In all of New Zealand
and Malaysia along with parts of
Australia and Canada, high school is
synonymous with secondary school, and
encompasses the entire secondary stage
of education.
======================================
Grade1 87.43%
Grade2 84.30%
Grade3 83.00%
=====================================
I want to parse the file and only get the numerical information. I looked into regex, and I think I'd use something like
if (m/^%/) {
do something
}
else {
skip the line
}
But, what I really want to do is keep track of the variable on the left and store the numerical value in that variable. So, after parsing the file, I'd really like to have the following variables to have the % value stored in them. The reason being, I want to create a pie-chart/bar graph of the different grades.
Grade1 = 87.43 Grade2 = 84.30
...
Could you'll suggest methods I should be looking at?