Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: hash key lookups failing

by ralphie (Friar)
on Nov 11, 2001 at 02:39 UTC ( [id://124612]=note: print w/replies, xml ) Need Help??


in reply to Re: hash key lookups failing
in thread hash key lookups failing

zaxo-
thanks for your reply. i know there's probably a better way to get the hash than the one i'm currently using, but the hash is there and populated appropriately. i actually used the arrayref method because of something i read here, though in all honesty i can't remember the full thought process that went behind it.

all this is beside the point. appropriate values are in the hash and in the scalar. the stuff is at work so i can't paste it in here. i'll concede that it is not inconceivable that the way i'm retrieving the hash might be affecting it's representation, thus affecting the ability of the exists function to find a value, but i think it's at least as likely that the dashes and colons in my constructed key are the source of the problem.

Replies are listed 'Best First'.
Re^3: hash key lookups failing
by Aristotle (Chancellor) on Nov 11, 2001 at 08:04 UTC
    exists has no "limitations". If it's in the hash, it can find it. I would rather guess you're passing it something you think looks right, which isn't; so exists() goes looking either for something other than you mean to tell it to, or in some place you didn't mean to tell it to - or both.

    You quite certainly don't want to write $vals=@keys[0];, it is $vals=$keys[0]; since the value you're getting back is a single scalar. $scalar = @array[0]; only works due to a mere coincidence in the language setup. Judging from so little evidence I can't be sure of course, but I suspect you come from a tranditional language and haven't yet fully understood the notion of scalar/list context; if so, you should realy work on that since otherwise you're likely to make a lot of mistakes with what will look like positively bizarre effects.

    But maybe we can clear up both points if you can paste some more of your code :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-25 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found