eval {open (FH, "directory/myfile") || die "Can Not open the file ($!)";}; if ($@){ # handle your exception # maybe check contents of $@ to decide what to do } @array = ; close(FH);