in reply to comparison of two arrays
use strict; my @arrayone = ('anu','abu','ali'); my @arraytwo = ('anu','abu'); my $arrays_match_result=match_arrays(\@arrayone,\@arraytwo); if($arrays_match_result==1) { print "Array's are the same\n"; }else{ print "Array's are not the same\n"; } sub match_arrays { my ($array1,$array2)=@_; my $el2cnt=0; my $not_the_same; for my $el1 (@$array1) { unless ($el1 eq @$array2[$el2cnt]) { $not_the_same=1; } $el2cnt++; } if($not_the_same==1) { return 0; }else{ return 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparison of two arrays
by lax (Initiate) on Jun 16, 2006 at 13:01 UTC | |
by dsheroh (Monsignor) on Jun 16, 2006 at 14:56 UTC | |
|
Re^2: comparison of two arrays
by lax (Initiate) on Jun 16, 2006 at 14:04 UTC |