in reply to Look ahead and join if the line begins with a +
# simplistic my @lines = scalar <FILE>; while (<FILE>) { if (s/^\+//) { $lines[-1] .= $_ } else { push @lines, $_ } } # fancy my @lines; while (<FILE>) { if (s/^\+//) { $lines[@lines && -1] .= $_ } else { push @lines, $_ } } # compact (UPDATED: 1 -> -1) my @lines; $lines[s/^\+// ? @lines && -1 : @lines] .= $_ while <FILE>;
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a (from-home) job
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Look ahead and join if the line begins with a +
by tachyon (Chancellor) on Apr 11, 2002 at 09:26 UTC | |
|
(MeowChow) Re2: Look ahead and join if the line begins with a +
by MeowChow (Vicar) on Apr 11, 2002 at 06:33 UTC | |
by tachyon (Chancellor) on Apr 11, 2002 at 09:11 UTC | |
by MeowChow (Vicar) on Apr 11, 2002 at 09:40 UTC | |
by tachyon (Chancellor) on Apr 11, 2002 at 10:06 UTC | |
by MeowChow (Vicar) on Apr 11, 2002 at 10:11 UTC | |
|
Re: Re: Look ahead and join if the line begins with a +
by Rhodium (Scribe) on Apr 11, 2002 at 14:56 UTC | |
by petral (Curate) on Apr 11, 2002 at 19:06 UTC |