use strict; use warnings; my $file = <}; close $fIn; print "1-->\n$str<--1\n"; $str =~ s/\n+\Z//; print "2-->\n$str<--2\n";