rendered paste body
# Code from perlfaq4 but modified to return 0 if equal:
sub compare_arrays {
my ($first, $second) = @_;
#no warnings; # silence spurious -w undef complaints
return 1 unless @$first == @$second;
print "test: " . scalar(@{$first->[0]}) . "\n";
for (my $i = 0; $i < @$first; $i++) {
for (my $j = 0; $j < scalar(@{$first->[$i]}); $j++) {
return 1 if $first->[$i][$j] ne $second->[$i][$j];
}
}
return 0;
}
my $foo = [ [ 1 , 2 ] , [ 3 , 4 ] ];
my $bar = [ [ 1 , 2 ] , [ 3 , 4 ] ];
print compare_arrays($foo,$bar) . "\n";
my $matt = [ [ 1 , 2 ] , [ 3 , 5 ] ];
print compare_arrays($foo,$matt) . "\n";
--- running
kirk:/home/mhavener> perl t.pl
test: 2
0
test: 2
1