my $contents = do { my $fh = IO::File->new($filename) or die "Failed to open $filename: $!"; $fh->getcontents(); }