>perl -wMstrict -le "my $s = '1a2b3c'; ;; print qq{no /o}; for my $i (qw(3 2 1)) { print qq{matched '$1'} if $s =~ m{ ($i.) }xms; } ;; print qq{with /o}; for my $i (qw(3 2 1)) { print qq{matched '$1'} if $s =~ m{ ($i.) }xmso; } " no /o matched '3c' matched '2b' matched '1a' with /o matched '3c' matched '3c' matched '3c' #### $pattern = 'Seuss'; while (<>) { print if /$pattern/; } #### #!/usr/bin/perl # Improved simple_grep $regexp = shift; while (<>) { print if /$regexp/o; # a good deal faster }