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

Re: file alteration

by FreeBeerReekingMonk (Deacon)
on Apr 14, 2015 at 17:50 UTC ( [id://1123431]=note: print w/replies, xml ) Need Help??


in reply to file alteration

That was fun: Here is a oneliner that does what you want:

perl -ne 'chomp; if (s/^A$// .. ($m=s/^B$//)){if($m){ print "A\n$p\B\n" if $p;$p=""}else{$p.=$_."\n" if $_} } ' datafile

see trick nr4 on https://blogs.oracle.com/ksplice/entry/the_top_10_tricks_of

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2024-04-16 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found