This construct is pretty common in perl:
opendir (B,"/somedir") or die "couldn't open dir!";
But this does not seem to work:
opendir ( B, "/does-not-exist " ) or {
print "sorry, that directory doesn't exist.\n";
print "now I eat fugu.\n";
exit 1;
};
Is it possible for the “or” error-handling to have more than one command?
Compiling the above:
# perl -c test.pl
syntax error at test.pl line 5, near "print"
syntax error at test.pl line 7, near "}"
test.pl had compilation errors.
You can always use
do:Or you can use if/unless:
Or you can swing together your own subroutine:
There is more than one way to do it.