Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Converting multiple lines into single line.

by Eily (Monsignor)
on Jan 09, 2018 at 13:33 UTC ( #1206974=note: print w/replies, xml ) Need Help??

in reply to Converting multiple lines into single line.

To detect that you are in your multiline section you can use the range operator (meaning "") and regular expressions.

/^war.*[{]/ means a line starting (the ^ means start) by war, followed by any character (the .) many times (the *) and a { ([] contains a list of allowed characters).
/[}]/ is a string containing }.
/^war.*[{]/../^war.*[{]/ checks $_ and is true between war.*{ and }. You can try this:

while (<DATA>) { if (/^war.*[{]/../[}]/) { $_ = "==> $_"; # Show the matching lines } print; } __DATA__ bla bla war eligible, init =0*DEC0, ev (VARIABLE){1*BIN0,2*DEC3,6*BIN4, & 5*BIN43,6*DEC32, & 5*BIN43,7*DEC32} bla bla

Now the tools you may need to complete the work can be: chomp to remove the newline, and tr to remove a character (or maybe s for a more complex modification)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2020-10-27 18:02 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (257 votes). Check out past polls.