in reply to Using Array::Diff
But i am unsure if this is what you were looking for but if anything in the new array is not found in the old array it is added to the old array and will be skipped if found again. A counter could be easily added as well on each non match.use strict; use warnings; my @old = qw(one two three); my @new = qw(one foo two bar three baz); print '@old array' . "\n"; print "$_\n" for (@old); print "\n" . '@new array' . "\n"; print "$_\n" for (@new), "\n"; foreach my $element (@new) { if ( $element ~~ @old ) { print "matched $element"; } else { print "\ndidnt match $element...Adding $element to old array\n +"; push( @old, $element ); } } print "\n" . '@old array' . "\n"; print "$_\n" for (@old);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Array::Diff
by Laurent_R (Canon) on Dec 03, 2014 at 07:48 UTC | |
by james28909 (Deacon) on Dec 03, 2014 at 08:11 UTC |