use Modern::Perl; use autodie; open my $fh,'>','filename.dat'; #will die() if it can't. say "Okay, the file's open, now let's do something.";