in reply to how to get a value corresponding to a key
What you have tried so far? You should go through perldata. Here is a small example.
%hash =("name" =>"john", "age"=>"25", "job"=>"programer", "location"=> +"US"); while (($key, $val) = each %hash) { if ($matchkey =~ /^$key$/) #if matches the particular key { $var = $hash{$key}; } }
or even simply,
$matchkey eq $_ ? $var = $hash{$_} : $var='' for keys %hash;
still simply as davorg suggested
$var = $hash{$matchkey}updated
Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to get a value corresponding to a key
by davorg (Chancellor) on Jul 20, 2005 at 12:10 UTC |