I'm a complete newbie to Perl, but I heard that this is great for parsing files, so I thought about giving it a spin.
I have a text file that contains the following sample information:
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 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 analyze the file and get only numerical information. I looked into the regex and I think Iβll use something like
if (m/^%/) { do something } else { skip the line }
But I really want to track the variable on the left and save the numeric value in this variable. So after parsing the file, I would really like to have the following variables in order to have the% value stored in them. The reason is because I want to create a pie chart / column chart of different classes.
Score 1 = 87.43 Grade2 = 84.30
...
Could you suggest methods that I should look at?
source share