martzpet has asked for the wisdom of the Perl Monks concerning the following question:
First file gives me keys and the first 3 values of the list:if ($hash{^$file}) { do something }
$thing is generally a serial number and is unique. In a few cases the serial number may be appended with (O) or (R). So there are 3 potential values:$hash{$thing} = (1,2,3)
second file gives me another 2 values for the list:serial serial(O) serial(R)
In this file, I am getting data based on serial number, but here there is never anything appended to serial number, so I have:push(@$hash{$thing},4,5)
In order to push, I am looking for the key that starts with serialserial
Due to the number of iterations, I am avoiding a foreach for the keys of $hash and I want to keep the (O) or (R) portion as it has significance. Can you do something like:^serial
if ($hash{^$file}) { do something }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex of hash key on the fly
by ikegami (Patriarch) on Nov 13, 2007 at 21:32 UTC | |
by martzpet (Initiate) on Nov 13, 2007 at 21:43 UTC | |
|
Re: regex of hash key on the fly
by locked_user sundialsvc4 (Abbot) on Nov 13, 2007 at 21:46 UTC | |
|
Re: regex of hash key on the fly
by dragonchild (Archbishop) on Nov 13, 2007 at 21:32 UTC |