#!/usr/bin/perl -w use strict; my %temphash = ( 't[0-3]om' => "good", "dick" => "bad", "hary" => "ugly" ); my $temp = 'This is a string containing t[0-3]om and dick'; my @results = map {my $var = quotemeta $_;$temp =~ /\b($var)\b/} keys %temphash; print "$_ matched\n" foreach(@results);