Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: to pick the common element in the array

by dorko (Parson)
on Oct 17, 2008 at 13:28 UTC ( #717730=note: print w/replies, xml ) Need Help??

in reply to to pick the common element in the array

Personally, I like List::Compare:
use strict; use warnings; use List::Compare; use Data::Dumper; my @array1=('a','2','3','2'); my @array2=('1','2','3','2'); my $lc = List::Compare->new(\@array1, \@array2); # Get those items which appear at least once in both lists (their inte +rsection). my @intersection = $lc->get_intersection; print Dumper \@intersection;
Also, use strict; and use warnings; caught the typos you made in defining the arrays.



-- Yeah, I'm a Delt.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://717730]
[stevieb]: I'm rather pleased with myself and everything I've leared along this arduous and sometimes frustrating path
[stevieb]: Just need to implement an email plugin or something so I can get alerted remotely if the status of a build has changed from the last run
[stevieb]: Because of the extreme complexity of the testing code itself, I implemented extensive logging so I can troubleshoot much easier by setting a high debug level.
[stevieb]: if you're interested in the test/build backend, have a look at Test::BrewBuild.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-04-28 21:50 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (529 votes). Check out past polls.