in reply to Using a regex as a hash key
or traverse the hash as usual:my $regex=qr/^Device(\s)+Configuration/; ... my $result = $functions{$regex}->($var2);
The check for this_is_the_key_I_want() is optional of course, or you could scan the regex itself as if it were a string, such as /Config/.my $result = undef; for (keys %functions) { if (this_is_the_key_I_want($_)) { $result = $functions{$_}->($var2); last; } }
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a regex as a hash key
by ikegami (Patriarch) on Jun 06, 2007 at 16:57 UTC | |
by halley (Prior) on Jun 06, 2007 at 17:04 UTC | |
by ikegami (Patriarch) on Jun 06, 2007 at 17:12 UTC |