Re: Appending lines starting with white space to the previous line reads the entire file into memory. This version processes the file line by line thanks to redo and a one line lookahead.
chomp( my $line = <$fh> ); while (defined($line)) { chomp( my $next = <$fh> ); if (defined($next) && $next =~ s/^\s+//) { $line .= $next; redo; } ... do something with $line ... $line = $next; }
Update: Tested. Small syntax fix.
In reply to Re: Appending lines starting with white space to the previous line
by ikegami
in thread Appending lines starting with white space to the previous line
by ashok13123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |