state-o-dis-array has asked for the wisdom of the Perl Monks concerning the following question:
and so on. I am creating a hash from this file in the form $hash{aa} = 0. I then split each line from the file that I'm checking:aa = 0 ab = 0 bb = 1 bc = 1 cc = 2 cd = 2
and make sure that@segments = split("_", $line);
and so on. First, does anyone have a better way of doing this? Second, is there a way to pattern match the keys of the hash without cycling through all the keys for each line of the file being checked? The reason I would like to do this is that the numbers that can be appended to a given segment are subject to change, and this means a lot of maintenance of the definition file, which I would like to avoid. I would like to do something like have a key be ab\d+ and be able to match that key to ab123, is this possible?$hash{$segment[0]} < $hash{$segment[1]}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash keys and regex
by DamnDirtyApe (Curate) on Dec 23, 2004 at 18:53 UTC | |
by state-o-dis-array (Hermit) on Dec 23, 2004 at 19:06 UTC | |
|
Re: hash keys and regex
by Aristotle (Chancellor) on Dec 24, 2004 at 01:40 UTC | |
by state-o-dis-array (Hermit) on Dec 24, 2004 at 15:46 UTC | |
by Aristotle (Chancellor) on Dec 24, 2004 at 16:06 UTC | |
by state-o-dis-array (Hermit) on Dec 24, 2004 at 18:56 UTC | |
by Aristotle (Chancellor) on Dec 25, 2004 at 02:55 UTC | |
|
Re: hash keys and regex
by blazar (Canon) on Dec 26, 2004 at 13:37 UTC |