Table of Contents


The or operator works as follows:

open STUFF, $stuff or die "Cannot open $stuff for read :$!";

This line means -- if the operation for opening STUFF fails, then do something else. Another example:


/^R/ or print "Doesn't start with R\n";

If the regular expression is false, then whatever is on the left side of the or is printed. As you know, shift works on @ARGV if no target is given, or @_ inside a subroutine.

Perl has two OR operators. One is the now familiar or and the other is || .