in reply to "array" search

I agree with Aristotle. You should probably use one of the existing Tie:: modules if what you're after is an ordered hash. If you decide not to do this, than the first solution he posted is much easier to read than what you had. He only forgot to replace
if ($key =~ m!^$id$!) {
with the much more efficient
if ($key eq $id) {

Replies are listed 'Best First'.
Re^2: "array" search
by Sheol (Novice) on Jan 14, 2006 at 08:21 UTC

    Well, some of the code, yes, I was thinking of making a Tie::Hash. (I think that is the module, it should be easy to figure out)

    Infact the idea of @{$self->{keys}} and @{$self->{values}} was taken from from code in articles on using Tie... right now I was mostly just getting it working first. (Well other than trying to cut down on me writting code over and over again)

    As per $key eq $id... I've read through a few documents and it is very confusing about how that operator works. Or maybe I am reading too deep into what eq does and how it opperates.

      eq is just like ==, except eq compares strings, and == compares numbers.