my %hash=(qr{([0-4])}=>"foo", a=>"foo2"); $_=2; for my $re (keys %hash) { P "re=%s, ref=%s", $re, ref $re; P "match:(%s) %s", $1, $hash{$re} if /$re/; } ' re=a, ref= re=(?^:([0-4])), ref= match:(2) foo