http://www.perlmonks.org?node_id=788859


in reply to remove line feed at the end

You should write print "$_ "; instead of print "$_\n";

Also, all the replacements within the if structure are not needed if you use "chomp", except one for getting rid of "\". See, for example, the following code:

#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; if($_ !~ /^{/){ $_ =~ s/\\//gi; chomp; print "$_ "; } } __DATA__ {AUTHOR} author1 staff1 {HEADLINE} DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST\ STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS.


produces:

author1 staff1 DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS.