On 26 Apr 2007, at 14:03, Clinton Gormley wrote: > > perldoc perlre [look for Backtracking] > > this doesn't require backtracking to work > > just do my ($match) = ($string =~ /(google|yahoo)/i)
my %despatch = ( 'yahoo' => sub { print "Yahoo!\n"; }, 'google' => sub { print "Google!\n"; }, ); my $match = join('|', map {quotemeta} keys %despatch); my $re = qr/($match)/i; # or whatever print "Using: $re\n"; for my $t ('I like yahoo', 'and also google') { $despatch{lc($1)}->() if $t =~ $re; } -- Andy Armstrong, hexten.net