Oh no! Its slower! I wrote a function implementing what is described above and its actually slower (about 1/2 as slow) than that huge thing I posted earlier. Does anything stand out here as being inefficient? Here it is:
(First glance stuff:)
sub compare { my $a = shift; my $b = shift;
If this is a 'real' sort operation this isn't necessary, and shouldn't even work. Perl will do this for you.
my $asciiDASH = 45; my $asciiDOT = 46;
These are legitimate constants. Declare them as such, outside of the subroutine. Then these assignments will only happen once, at compile time. (Instead of _every_ time the sort calls this routine.)
my @a = unpack("C*", $a); my @b = unpack("C*", $b);
This can also be done with a: my @a = split //, $a; # (That is a null pattern.)
I'm not sure if split or unpack is faster, I'll have to benchmark in the morning.
Daniel T. Staal
--------------------------------------------------------------- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. ---------------------------------------------------------------
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>