#!/usr/bin/perl use strict; use warnings; my @a = (1, ,2, 10, undef, "", '-0', , 'b', ""); my @b = (1,,02, 1e1, undef, "", '-0', , 'a',undef); if (compare(\@a, \@b)){ print "ok\n"; }else{ print "not ok\n"; } my @c= ( 10, 99999999999999999999999999999 , 0xf, 'a', "0", -0.0); my @d= ( 1e1, 99999999999999999999999999999.01, 15, 'a', 0 , +0.0); if (compare(\@c, \@d)){ print "OK\n"; }else{ print "NOT OK\n"; } my @e = ( 'Ein' ); my @f = ( 0 ); print "ok\n" if (compare(\@e,\@f)==1); print "not ok\n" if (compare(\@e, \@f)==0); my @i = (chr(int rand(256))) x 100_000; my @j = @i; use Benchmark; timethese( -3, { 'ver' => '$k = compare (\@i, \@j);', }); sub compare { my ($x, $y) = @_; no warnings; return 0 if (@$x != @$y); for (0..$#$x){ return 0 unless ( $x->[$_] eq $y->[$_] ) && ( $x->[$_] == $y->[$_] ) && ( defined ($x->[$_]) == defined ($y->[$_]) ); } return 1; }