On May 23, Craig Hammer said:
>Very nice explanation. One thing though, I am not using uniq to remove
>duplicates. I am using it to get a count of duplicates. In my case, I am
>creating a threshhold to determine when someone (malicious) is scanning my
>address ranges.
Ah, I see. Well then, you can use either method to obtain the count:
# a -- from perlfaq4
my $prev = "NO_SUCH_VALUE";
my $dup = 0;
my @sorted = grep { $_ ne $prev ? $prev = $_ : ++$dup } sort @records;
# b -- also from perlfaq4
my %seen;
my @sorted = sort grep { !$seen{$_}++ or ++$dup } @records;
I'd probably go with a) though, for the following reasons:
1. you said you want to sort everything anyway
2. we don't need to use a hash
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]