my $re1 = qr{([0-4])}; my $re2 = qr{([5-9])}; my %hash = ("$$re1" => "foo", "$$re2" => "bar"); $_ = "-5-"; for my $re (keys %hash) { print "match: ($1) $hash{$re}\n" if /$re/; } # outputs: # match: (5) bar