Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by MeowChow (Vicar)
on Apr 11, 2002 at 09:40 UTC ( #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


Comment on (MeowChow) Re4: Look ahead and join if the line begins with a +
Select or Download Code
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
Node Status?
node history
Node Type: note [id://158268]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2015-07-01 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls