in reply to trim the blank lines...regex
while ( <> ) { chomp; print "$_\n" if length $_; }
If you're playing golf:{ local $/; my $contents = <>; $contents =~ tr/\n/\n/s; print $contents; }
$/='';chomp,print"$_\n"while<>
print/./?$_:''while<>
If you're using one-liners:print/./?$_:''for<>
perl -ne "print if/./"
perl -0pe "y/\n/\n/s"
perl -ne "/./&&print"
|
|---|