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

Re: Converting multiple lines into single line.

by Eily (Prior)
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 "from..to") 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2019-02-21 05:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (109 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!