Just figured I'd add another way to do it...
sub quote_eq {
return "@a1" eq "@a2";
}
And the results were....
Benchmark: timing 100000 iterations of join, loop, quote...
join: 3 wallclock secs ( 2.30 usr + 0.00 sys = 2.30 CPU) @ 43
+402.78/s (n=100000)
loop: 17 wallclock secs (16.03 usr + 0.00 sys = 16.03 CPU) @ 62
+37.52/s (n=100000)
quote: 5 wallclock secs ( 3.79 usr + 0.00 sys = 3.79 CPU) @ 26
+420.08/s (n=100000)
join remains in the lead...
Update: Of course this has the same bug that
lhoward pointed out. Assuming lists of single character elements though... :)
Update 2: Alright, so not the same bug, but a similar bug - as
btrott points out... i.e.
my @a1 = ( "3 5 7", "9 11 13" );
my @a2 = qw( 3 5 7 9 11 13 );
result in the same string.
So this algorithm can be used to compare arrays where the elements don't have whitespace... any array created with the qw operator...