Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Perl Newline Help

by Loops (Curate)
on Nov 11, 2014 at 18:41 UTC ( #1106869=note: print w/replies, xml ) Need Help??


in reply to Perl Newline Help

Not beautiful, but gets the job done:

while (<DATA>) { if (/^FILE/ && split(/[\s\\]+/) == 5) { my ($num,$trail) = <DATA> =~ m/^\s*(\d+)\s*(.*)$/s; s/\s*(?=\\\s*$)/ $num /s; print; print $trail; } else { print; } } __DATA__ FILE TEXT VAL 9999.999 08-jul-2014 \ 270 3E4497B6B8482ADED734 HDNDFLHWLEJHFL LKSNFLKN \ WKENFLWHFELHN UIEKEFJBKJFN FILE TEXT2 VAL 9999.999 16-may-2014 60 \ 8EC4B7367989D54F6D6C HSHFGFLALKHF KJAHEFKHAH\ YRNBFLJNELFN LQJFLKJWEF LKJFLKWJF

Prints:

FILE TEXT VAL 9999.999 08-jul-2014 270 \ 3E4497B6B8482ADED734 HDNDFLHWLEJHFL LKSNFLKN \ WKENFLWHFELHN UIEKEFJBKJFN FILE TEXT2 VAL 9999.999 16-may-2014 60 \ 8EC4B7367989D54F6D6C HSHFGFLALKHF KJAHEFKHAH\ YRNBFLJNELFN LQJFLKJWEF LKJFLKWJF

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-05-22 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (80 votes). Check out past polls.

    Notices?