in reply to compare two arrays
TIMTOWTDI again.
use strict; use warnings; my @arr1 = ( 1, 2, 4, 5, 3 ); my @arr2 = ( 1, 2, 4, 2, 3 ); my @diff = map m{\0} ? 1 : 0, split m{}, join( q{}, @arr1 ) ^ join( q{}, @arr2 ); print qq{@arr1\n@arr2\n@diff\n};
The output.
1 2 4 5 3 1 2 4 2 3 1 1 1 0 1
Cheers,
JohnGG
Update: As pointed out by jwkrahn, this is a stupid solution that only works because all elements are one character. Please ignore or downvote. I'll get my coat.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: compare two arrays
by jwkrahn (Abbot) on Dec 15, 2008 at 11:18 UTC | |
by johngg (Canon) on Dec 15, 2008 at 12:47 UTC |