#! perl -slw use strict; my $pat1 = "field"; my $pat2 = "f.i.e.l.d"; my $pat3 = "the"; my $str = "There are many soccer fields in England - f1i2e3l4d"; while( $str =~ m/((?'A'$pat1)|(?'B'$pat2)|(?'C'$pat3))/ig ){ printf "Found '$1' from pattern '%s'\n", grep{ defined $-{ $_ }[ 0 ]; } keys %-; } __END__ C:\test>junk Found 'The' from pattern 'C' Found 'field' from pattern 'A' Found 'f1i2e3l4d' from pattern 'B'