Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Regex copy and paste help

by roboticus (Chancellor)
on Aug 31, 2012 at 10:56 UTC ( #990982=note: print w/replies, xml ) Need Help??

in reply to Regex copy and paste help


I'd suggest something like this:

Keep two sets of fields: the temporary set and the full set you're building.

  • Read a line and parse it into the temporary fields (unpack, substr)
  • If the first column exists (e.g. A00004) then it looks like you're on a new item, so:
    • If you have anything in the "full" set:
      • process it
      • write the processed data
    • Copy the temporary data into your "full" set
  • Otherwise
    • Append the existing temporary fields into your full set
  • then go back and process the next line

Finally, when you're done, if you have anything in your full set, process it.


When your only tool is a hammer, all problems look like your thumb.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990982]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2017-11-20 14:15 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (286 votes). Check out past polls.