in reply to append line to previous line in txt file
Works with empty files and files that begin with a ;do { $n = chomp; print; $_ = <>; print $/ x $n unless s/^;//; } while defined($_);
Update: This is just another way to think about the problem. You don't have to start every file reading loop with while (<>).
Update 2: Changed unless /^;/ to unless s/^;// which addresses concerns about it not working with consecutive lines beginning with a semi-colon.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: append line to previous line in txt file
by johngg (Canon) on Jul 09, 2008 at 10:29 UTC | |
by pc88mxer (Vicar) on Jul 09, 2008 at 13:34 UTC | |
by johngg (Canon) on Jul 09, 2008 at 21:23 UTC |