Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(MeowChow) Re4: Look ahead and join if the line begins with a +

by MeowChow (Vicar)
on Apr 11, 2002 at 09:40 UTC ( [id://158268]=note: print w/replies, xml ) Need Help??


in reply to Re: (MeowChow) Re2: Look ahead and join if the line begins with a +
in thread Look ahead and join if the line begins with a +

I based my code on japhy's solutions, none of which were stripping newlines, probably because Rhodium didn't specify if he wanted them removed, or the lines to be simply concatenated as-is into single list items.
$lines[ @lines + 1 - s -^\053|\012--g ] .= $_  while <DATA>;
This fails by adding an undef element to the array if a newline is not the final character in the file. Changing my original easy enough though, without any regex or substr nastiness:
chomp, $lines[@lines - s/^\+//] .= $_ while <DATA>;
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: (MeowChow) Re4: Look ahead and join if the line begins with a +
by tachyon (Chancellor) on Apr 11, 2002 at 10:06 UTC

    Touche. But.....

    chomp, $lines[@lines - s/^\+//] .= $_ while <DATA>; __DATA__ + Oops, Just another Edge case

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Well, didn't I say it was a vulgar solution? :-)
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-26 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found