for (qw{dog pig cat horse}) {
/.o${print "$_ gets printed\n";\''}/ and print "$_ matched\n";
}
__END__
dog gets printed
dog matched
pig gets printed
cat gets printed
horse gets printed
horse matched
####
for (qw{dog pig cat horse}) {
/.o(?{print "$_ gets printed\n"})/ and print "$_ matched\n";
}
__END__
dog gets printed
dog matched
horse gets printed
horse matched
####
for (qw{dog pig cat horse}) {
/.o(??{print "$_ gets printed\n"; 'g'})/ and print "$_ matched\n";
}
__END__
dog gets printed
dog matched
horse gets printed