Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: To Hash or to Array--Uniqueness is the question.

by sauoq (Abbot)
on Dec 01, 2005 at 22:45 UTC ( #513466=note: print w/ replies, xml ) Need Help??


in reply to To Hash or to Array--Uniqueness is the question.

When collecting data that you only want unique values from, would you:

That depends on what your "values" are. If they are just strings or can be represented in a canonical form as strings than go ahead and use a hash. If the values in question are something more complex, then a hash isn't going to work for you as the keys of a hash must be strings.

-sauoq
"My two cents aren't worth a dime.";


Comment on Re: To Hash or to Array--Uniqueness is the question.
Re^2: To Hash or to Array--Uniqueness is the question.
by cowboy (Friar) on Dec 02, 2005 at 22:50 UTC
    Tie::RefHash can be used to allow references to be used as keys. I use it to allow the use of filehandles as a key, without losing their magic.

      Sure, but in the context of this question—which is about dealing with uniqueness—that's not likely to be very helpful. Unless, of course, the uniqueness of the reference itself is sufficient. But if you have, say, my $a = [1]; my $b = [1]; and want to insert them into a store only if an identical structure doesn't already exist in that store... Tie::RefHash probably won't help because you'll need to do a 'deep' compare.

      -sauoq
      "My two cents aren't worth a dime.";
      

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-12-18 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls