in reply to Re: merging two arrays with OR operation
in thread merging two arrays with OR operation
Much nicer than mine!! (see below, I forgot to put mine)
use Data::Dumper; my @array1 = (0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1); my @array2 = (0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1); my @result; if (@array1 != @array2) { $equals = 0; } else { $equals = 1; foreach (my $i = 0; $i < @array1; $i++) { if (($array1[$i] eq 0)&&($array2[$i] eq 0)) { push (@result, 0); } else{ push (@result, 1); } } } print Dumper \@result;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: merging two arrays with OR operation
by GrandFather (Saint) on Mar 06, 2019 at 20:18 UTC |