That seems rather a long way to go about it. What does your method give you that simply using $var = $hash{$matchkey} doesn't?
Also why use $matchkey =~ /^$key$/ when $matchkey eq $key achieves the same thing without the overhead of invoking the regex engine? Regular expressions are a powerful tool, but they are often unnecessarily complex for the task in hand.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re^2: how to get a value corresponding to a key
by davorg
in thread how to get a value corresponding to a key
by s_gaurav1091
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |