in reply to Look ahead and join if the line begins with a +
The other methods listed here are probably more efficient, especially if you're going to do something with the lines individually later. However, since you're preloading the file into memory as it is, here's something simpler:
use strict; my $all_text; { local($/); $all_text = <NETLIST>; } $all_text =~ s/\n\+/ /gs; print $all_text;
You might want to check out Text::Wrap for reflowing it.
stephen
Update: Thanks to japhy for pointing out a mental misstep on my part...
Update 2: Thanks to broquaint for a reminder on local()...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Look ahead and join if the line begins with a +
by japhy (Canon) on Apr 11, 2002 at 04:46 UTC | |
Re: Re: Look ahead and join if the line begins with a +
by broquaint (Abbot) on Apr 11, 2002 at 10:36 UTC | |
Re: Look ahead and join if the line begins with a +
by Smylers (Pilgrim) on Apr 11, 2002 at 08:52 UTC |
In Section
Seekers of Perl Wisdom