use strict; use warnings; my $file = shift; # file to process is the 1st command line argument open my $fh, $file or die; $_ = join '', <$fh>; # make file's content one (big?) line close $fh; s{__END__.*}{}s; print;