in reply to Slurp a file

You need to check whether open fails and report a useful error. Here is a trick to do that for you:

my $contents= do { local(*ARGV,$/); @ARGV="myfile.txt"; <> };
Though I'm taking on faith that local(*ARGV) will properly save and restore everything that <> manipulates. (:

        - tye (but my friends call me "Tye")