in reply to Re^2: remove line feed at the end
in thread remove line feed at the end
That's good. Looks like it works as designed.
If you want to do special things when \ appears at the end of a line, then you should recognize it and do special things.
You are only removing it from the line and then go on with the standard action...
Consider something like this:
#!/usr/bin/perl use strict; use warnings; my $output = ''; LINE: while ( my $line = <DATA>) { chomp $line; # if line ended with a '\', remove '\' and save line for later out +put if ( $line =~ s/\\$// ) { # clean indentation $line =~ s/^\s+/ /; # save line $output .= $line; next LINE; } # we have previous line(s) to consider? elsif ( length $output ) { # clean indentation $line =~ s/^\s+/ /; $line = $output . $line; $output = ''; } print $line, $/; } __DATA__ {FILE} sourcetag1 {NUMBER} 00000 11111 {SOURCE} source1 {KEYWORD} {AUTHOR} author1 staff1 {HEADLINE} DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST\ STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS +. {FILE} sourcetag2 {NUMBER} 00002 {SOURCE} sourcenam2 {KEYWORD} {AUTHOR} author2 staff2 a\ b\ c
It's your exercise to combine this with your code ;o)
BTW: why do you use the /i modifier, when replacing spaces, newlines or the backslash?
In Section
Seekers of Perl Wisdom