That looks like you do not have Inline::C installed correctly, but I can't help you with that. If it is the case...ie. if the Inline::C installation tests are failing, then you shoudl post a new thread about that to get help.
In the interim, you can try this pure perl version which is only half as fast as the inline version, but that should still be 7 times faster than your current solution. Let me know how you get on.
#! perl -slw
use strict;
use Time::HiRes qw[ time ];
$|++;
sub uniq{ my %x; @x{@_} = (); keys %x }
my $start = time;
my @uniq = uniq <>;
chomp @uniq;
@uniq = sort{ length $a <=> length $b } @uniq;
my $all = join chr(0), @uniq;
my $p = 0;
for my $x ( @uniq ) {
$p += 1+ length $x;
next if 1+ index $all, $x, $p; ## COrrected per LanX below.
print $x;
}
printf STDERR "Took %.3f\n", time() - $start;
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|