Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^4: lsearch for perl?

by thor (Priest)
on Dec 05, 2005 at 19:40 UTC ( #514214=note: print w/replies, xml ) Need Help??

in reply to Re^3: lsearch for perl?
in thread lsearch for perl?

I meant association in a looser sense than you mention above. For the first set, you're associating passwords with their respective users. In the second set, you're associating the given values with their type ("joe" is the "id" for this user). As for the uniqueness condition, I agree that it's useful, but not a hash's intended use. Incidentally, I think that the following loop uses less memory:
my %unique; $unique{$_} = undef foreach @list; @list = keys %unique;
due to the undef being shared amongst all of the keys of the hash. That may be an urban legend that I heard somewhere, though. ;)


The only easy day was yesterday

Replies are listed 'Best First'.
Re^5: lsearch for perl?
by ikegami (Pope) on Dec 05, 2005 at 19:44 UTC
    I'm pretty sure undef uses less mem, and it's probably a bit faster, but ++ allows you to check which items had duplicates. undef @unique{@list}; is actually fastest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://514214]
[Lady_Aleena]: marioroy, it is used in 24 other modules I wrote.
[Lady_Aleena]: GUH! I wrote a script better than I thought! 8)
[marioroy]: Wow. It's cool seeing Github coments "Update, Create Wild_hairs, Create alternate- PurpleOnGreen..., Then a location, Create Aleenia. Amazing, really. Thank you for sharing.
Discipulus when naming is clear and you know how to arrange the data, then coding it is a mere writing work

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-05-29 09:07 GMT
Find Nodes?
    Voting Booth?