Think about Loose Coupling | |
PerlMonks |
Re: Bug in script when users use long namesby boftx (Deacon) |
on Sep 25, 2013 at 00:28 UTC ( [id://1055574]=note: print w/replies, xml ) | Need Help?? |
I will offer a (very) general approach, or hint rather. It appears that your data samples, especially sample 2, represents a form of fixed length records that consist of a header record that can be identified by have a non-space character in col 1 (assume 1-based col numbering) and continuation records identified by space characters in cols 1 and 2. Given that you can easily find the start of a master record, and that there appears to be a standard structure to the continuation records, then unpack becomes your best friend and makes the actual extraction trivial. The presence of the header title records is what reduces this to a simple problem that unpack is uniquely intended to handle. All that you really need to do is keep track of what record/sub-record row number you are on so you apply the correct unpack pattern to it and extract the data to normal variables.
On time, cheap, compliant with final specs. Pick two.
In Section
Seekers of Perl Wisdom
|
|