$ perl -le'(join "\n", qw(foo bar baz)) =~ /(.*\n)/m && print $1' foo $ # note the embedded newline