my $error; opendir(DIR, $dir) or $error = Carp::shortmess("Could not open $dir"); mail($error) and die $error if $error;