http://www.perlmonks.org?node_id=717730


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.

Cheers,

Brent

-- Yeah, I'm a Delt.