Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Using a regex as a hash key

by halley (Prior)
on Jun 06, 2007 at 17:04 UTC ( [id://619630]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using a regex as a hash key
in thread Using a regex as a hash key

ikegami, I recognized that it's a TRH, but it still behaves like a hash including iteration, as well as the extra features and odd non-1:1 key behavior. If he doesn't have anything for a key (his missing $val1), he'll have to start somewhere.

Perhaps I should have said he could just assign $val1 = 'Devices Configuration for Hard Drives' to pick out one particular key, or the hail-mary dispatch loop that citromatik offers where you just throw any old $_ in there and hope it sticks.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^4: Using a regex as a hash key
by ikegami (Patriarch) on Jun 06, 2007 at 17:12 UTC

    Sorry, it sounds like I needed to be more explicit.

    %functions is a Tie::RegexpHash, so your suggestion of $functions{$regex}->($var2); is wrong — Use a normal has for that — and a step in the wrong direction. The key for lookups should not be a regexp, but a value to match against the existing keys.

    Looping over all the keys is even worse. The whole point of Tie::RegexpHash is to save you from doing that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://619630]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found