Hello ramachandrajr,
See also perlfaq4. Here is one (not necessarily optimal) way, using 2 modules:
#! perl use strict; use warnings; use List::Util qw( pairfirst ); use List::MoreUtils qw( mesh ); my @array1 = qw( a e i o u ); my @array2 = qw( a e i o u ); my $found = @array1 == @array2 && ! pairfirst { $a ne $b } mesh @arra +y1, @array2; print $found ? 'Match' : 'No match', "\n";
Output:
18:12 >perl 1380_SoPW.pl Match 18:12 >
Hope that helps,
Update (13 Aug 2020): Fixed broken link.
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: any replacements for smartmatch on comparing two arrays
by Athanasius
in thread any replacements for smartmatch on comparing two arrays
by ramachandrajr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |