Your skill will accomplish
what the force of many cannot
More Regular Expressions (text data handling)by graq (Curate)
|on Dec 04, 2001 at 16:33 UTC||Need Help??|
graq has asked for the
wisdom of the Perl Monks concerning the following question:
I am writing a script that takes some raw data (text), extracts the set of information and inserts into a database. Wow, big surprise you all say. Yeah, well, I have a feeling that I am not doing this particularly well.
The thing that is making it non-trivial is that the rules for the data are not as trivial as usual. I don't think I will explain the rules, but rather give an example.
(Name is Graq, Number is 634321, age 27, jameson is my fave drink, detest bells etc)
Now this data is also surrounded by further noise, and may contain extra blank lines.
But the 'Number' tag is unique, and there is always exactly
70 lines of (non-empty) relavent data, so I can index
that and grab the lines I need.
So this gives me an array of 'useful' data. A big thanks to people in CB for some of the individual lines in there, but it is all starting to look a little clumsy (and I am stripping some unwanted values at )
So.. to my point. I am looking for some help in handling this data, preferably into a hash, so that I can do stuff with it.
Anything ranging from help on the individual REs to new approaches on tackling the problem as a whole. Am I just kicking a dead horse and might aswell write something a lot less generic?