Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Homework question list

by runrig (Abbot)
on May 23, 2005 at 22:59 UTC ( [id://459745]=note: print w/replies, xml ) Need Help??


in reply to Re: Homework question list
in thread Homework question list

Smart people use hash slices. Really smart people use 'undef'd hash slices to save memory.

undef'd hash slices save time not memory.

Update: Also, as pointed out to me in a previous post, only use this method if you don't care about the values of the hash, as the values do not necessarily get set to undef.

Replies are listed 'Best First'.
Re^3: Homework question list
by TomDLux (Vicar) on Oct 29, 2010 at 17:51 UTC

    I notice that in five years no one has filled in the details of the concise implementation.

    # given two arrays you want to compare for common elements, @a1 & @a2 +... my %common; undef @common{@a1}; delete @common{@a2}; my @common = keys %common; #for example: DB<1> @a1 = qw(a b c d e) DB<2> @a2 = qw(a c e ) DB<3> undef @common{@a1} DB<4> x \%common 0 HASH(0x8408418) 'a' => undef 'b' => undef 'c' => undef 'd' => undef 'e' => undef DB<5> delete @common{@a2} DB<6> x \%common 0 HASH(0x8408418) 'b' => undef 'd' => undef DB<7> print join " ", keys %common b d

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found