in reply to Re^4: Wildcard in a hash
in thread Grep asterisk sign in input file
thanks, but in the loop of read input file, "if ($pins1 =~ /^$key$/) ", the dollar sign, $ will have to be removed too.
This applys only if you want a partial match of the keys. A key like c4a would then match c4a_123[3] also.
You could escape the brackets:
$pins2 =~ s/\*/.*/; # make key into regex string if containing * $pins2 =~ s/([\[\]])/\\$1/g; # escape brackets c4a_123[3] -> c4a_1 +23\[3\]
That way the brackets aren't treated as a character class whilst matching the keys.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Wildcard in a hash
by DespacitoPerl (Acolyte) on Aug 17, 2017 at 09:38 UTC |