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 17:35 UTC ( #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
Node Status?
node history
Node Type: note [id://582188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2019-02-24 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (121 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 18:53 UTC) Welcome new users!