The veritcal bar/pipe/or can be used to provide a choice between matches. If one part of the pattern fails, the part of the right gets a chance to match.
\!h # Basic Example:
foreach (qw(fred betty barney dino)) {
if (/fred|barney/) {
print "$_ matched\n" # this would return both names, because both are matching
}
}
\!h # Different example - make your pattern case insensitive
$_ = "Bamm-Bamm";
if (/Bamm-?(B|b)amm/) {
print "The string has Bamm-Bamm\n";
}
# Now the second 'bamm' can can start lower or uppercase