Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Is it possible to insert a record after line 5 that appears on line 10?

by AndyZaft (Hermit)
on Jun 23, 2010 at 21:47 UTC ( #846185=note: print w/replies, xml ) Need Help??


in reply to Is it possible to insert a record after line 5 that appears on line 10?

Been at least 15 years since I worked in a bank, but because of it I always assume all data files can come in massive sizes, so based on that my solution would be something along the lines of ...

Print everything till you hit :17B:, then you consider this the start of a record to watch for. Feed the lines that follow to an array till the first :35B: record, at which point you are ready to process this "block" between 17B and 35B. If there was a :16R:SECMOVE in between you print the first record of array, then the last, and then the rest, minus the last one, then go back to printing rows till you hit :17B: again. Of course spit out the array if there was no :16R:SECMOVE in there. Don't forget to empty the array before reuse.

Obviously if :16R: can occur before :17B: and still need to process it that way, just modify accordingly. Guess it would help if I knew anything about these records and if they have any kinda order or whatnot. You could probably do this as an AWK oneliner too.

  • Comment on Re: Is it possible to insert a record after line 5 that appears on line 10?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-02-23 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (301 votes). Check out past polls.

    Notices?