Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Add black line between two consecutive lines starting with specified strings

by AnomalousMonk (Archbishop)
on Feb 10, 2018 at 02:31 UTC ( [id://1208875]=note: print w/replies, xml ) Need Help??


in reply to Add blank line between two consecutive lines starting with specified strings

It is certainly possible. Assuming Windows command line (update: and assuming "black" means "blank"), try (semi-tested):

perl -wMstrict -pe "BEGIN { our $armed } $::armed = /\A \\macroa \s/x +? 1 : /\A \\macrob \s/x && $::armed && ! print qq{\n}" infile > outfi +le


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Add blank line between two consecutive lines starting with specified strings
by texuser (Novice) on Feb 10, 2018 at 05:02 UTC
    Thank you, it works.

      I'm glad it works, and you're welcome. Do you understand why it works? We do not aspire to be a code-writing service. Evidence of effort on your part will beget effort on ours. Looking at your admittedly limited posting history ...


      Give a man a fish:  <%-{-{-{-<

        I am grateful for the help I got here. I am new to this. Now that I have some working code I can study perl syntax to understand how to do things and not ask simple questions anymore. I have also found the perl oneliner site which is very useful. Thanks again.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-19 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found