Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Open file, sort data on matching field, close fileby punch_card_don (Curate) |
on Apr 30, 2009 at 12:27 UTC ( [id://761083]=note: print w/replies, xml ) | Need Help?? |
This will likely have to be a multi-pass process. It appears that you have a well known set of of fields that appear to order nicely into sql-like tables:
employee_info And you know, it appears, that data grouped on successive lines relate to each other and that groupings are separated by blank lines, and that data tags and their value are spearated by a colon. So, go through the file line by line, read data into a buffer by reading forward until you hit a blank line, then store that into temporary hashes as if in sql tables. Once it's all compiled, then output your total file. pseudo-code:
Time flies like an arrow. Fruit flies like a banana.
In Section
Seekers of Perl Wisdom
|
|