in reply to Comparing Arrays
And the results were....sub quote_eq { return "@a1" eq "@a2"; }
join remains in the lead...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)
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...my @a1 = ( "3 5 7", "9 11 13" ); my @a2 = qw( 3 5 7 9 11 13 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Comparing Arrays
by btrott (Parson) on Sep 01, 2000 at 22:51 UTC | |
by lhoward (Vicar) on Sep 01, 2000 at 23:00 UTC | |
by jlistf (Monk) on Sep 01, 2000 at 23:09 UTC | |
by merlyn (Sage) on Sep 01, 2000 at 23:12 UTC |