For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Re: compare 2 arrays...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: compare 2 arrays...
Devi

2006-10-13, 7:56 am

Hi,

sry.. typo mistake

foreach my $a1(@array1) {
if($a2!=~/,$a1,/)
{
push @not_in_array2, $a1;
}
}

Thanks
Devi

Devi wrote:[color=darkred]
> Hi,
>
> try this,
>
> my @array1 = qw /red blue green white/;
> my @array2 = qw /red black green white/;
> my @not_in_array1;
> $"=",";
> my $a2="," . "@array2" . ",";
> $"=" ";
>
> foreach my $a1(@array1) {
> if($a2!=~/,$a1,/)
> {
> push @not_in_array1,$a1;
> }
> }
>
> Thanks
> Devi.
>
> onlineviewer wrote:

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com