open my $fh, '+<', $theFile or die $!; my $stuff = do{ local $/; <$fh> }; truncate $fh, 0; close $fh;