Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: My 'perldar' tells me there is a 'better' solution for this list operation

by Sidhekin (Priest)
on Nov 03, 2006 at 22:35 UTC ( [id://582188]=note: print w/replies, xml ) Need Help??


in reply to My 'perldar' tells me there is a 'better' solution for this list operation

If you judge whether a value is "present" by string equality (and it would seem you do), you could just use a hash:

my %map; @map{@l2} = (); my @list = map { exists $map{$_} ? $_ : 'null' } @l1;

( Also: "perldar"++ )

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found