opendir (DIR, $directory) || do { # your error handling here... };