I have two arrays, @a and @b. I want to do a compare among the elements of the two arrays.
@a
@b
my @a = qw\"abc def efg ghy klm ghn\"; m
This is one way:
use warnings; use strict; my @a = split /,/, "abc,def,efg,ghy,klm,ghn"; my @b = split /,/, "def,ghy,jgk,lom,com,klm"; my $flag = 0; my %a; @a{@a} = (1) x @a; for (@b) { if ($a{$_}) { $flag = 1; last; } } print "$flag\n";