my $x = "(quantifier)"; my %x = ( "1" => "(hash_value)" ); my $z = 'quantifier hash_value'; my $ele = $x{1}; print "_$1_\n" if $z =~ /$ele/;