in reply to Appending lines starting with white space to the previous line

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Appending lines starting with white space to the previous line
by linuxer (Curate) on Jan 07, 2009 at 11:56 UTC

    yes, that's possible, but why don't you show the code you tested?

    I modified my example and the result looks like the wanted...

    while ( my $line = <DATA> ) { chomp $line; # remove the spaces from start of line if ( ! ( $line =~ s/^\s+// ) ) { print "\n" if $. != 1; } # remove spaces from end of line $line =~ s/\s+$//; print $line; } __DATA__ firstline54324563213612531436436463246324634 secondlidfndsfdsfdsfd thirdlinedsfsdf firstline54324563213612531436436463246324634 secondlidfndsfdsfdsfd thirdlinedsfsdf

    Result:

    $ perl guess.pl firstline54324563213612531436436463246324634secondlidfndsfdsfdsfdthird +linedsfsdf firstline54324563213612531436436463246324634secondlidfndsfdsfdsfdthird +linedsfsdf