Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Iterator to parse multiline string with \\n terminator

by jwkrahn (Monsignor)
on Oct 06, 2013 at 08:26 UTC ( #1057129=note: print w/replies, xml ) Need Help??

in reply to Iterator to parse multiline string with \\n terminator

open my $fh, '<', $filename or die "Cannot open '$filename' because: $ +!"; while ( <$fh> ) { chomp; if ( s/\\$// ) { $_ .= <$fh>; redo; } # now complete line in $_ }

Replies are listed 'Best First'.
Re^2: Iterator to parse multiline string with \\n terminator
by three18ti (Scribe) on Oct 06, 2013 at 09:08 UTC
    What's the difference between using redo and using next as a similar example above does?

      next goes back to:

      while ( <$fh> ) {

      And therefore reads the next line into $_ while redo goes back to the line after that leaving $_ unchanged.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057129]
[robby_dobby]: marto: Good morning, I usually spend my Fridays here cursing the bloody weather!
[marto]: where are you based robby_dobby?
[robby_dobby]: marto: Oh, I see you're from an even colder north :-)
[robby_dobby]: marto: Ldn, right now
[marto]: icy here today, snow on the hills
[Corion]: Oh yes, Friday!
[Corion]: Last day at $work before 3 weeks of vacation (well, not that I'd be really travelling, but no-work-time ;) )

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-12-15 10:31 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (430 votes). Check out past polls.