- or download this
use strict;
my (@keywords, %keyword)=qw/foo bar 12345 abcd/;
my ($string, %result) = "foobarfoo1234523423412345abcdefsadfabc";
- or download this
@keyword{@keywords} = map {qr/\Q$_\E/} @keywords; - or download this
$result{$_} = () = $string =~ $keyword{$_}
for (keys %keyword);
- or download this
my @regexen = map {
qr/(?:\Q$_\E(?{$result{$_}++}))/
} @keywords;
...
local $" = '|';
qr/@regexen/;
};
- or download this
$string =~ /$re/g;
print "$_: $result{$_}\n" for @keywords;