rockdoc
04-01-2006, 07:30 AM
Hello,
I'm trying to find out how many values in @sorted are less than or equal to the values in @unique
@sorted = (3 12 16 56 56 78 92 99 99)
@unique = grep { ++$count{$_} < 2 } @sorted; # (3 12 16 56 78 92 99)
i.e.
There is 1 value in @sorted less than or equal to 3
... 2 values in @sorted less than or equal to 12
... 3 values in @sorted less than or equal to 16
... 5 values in @sorted less than or equal to 56
etc etc
I just want to return those values to another array
@count = (1 2 3 5 etc );
Any suggestions?
I'm trying to find out how many values in @sorted are less than or equal to the values in @unique
@sorted = (3 12 16 56 56 78 92 99 99)
@unique = grep { ++$count{$_} < 2 } @sorted; # (3 12 16 56 78 92 99)
i.e.
There is 1 value in @sorted less than or equal to 3
... 2 values in @sorted less than or equal to 12
... 3 values in @sorted less than or equal to 16
... 5 values in @sorted less than or equal to 56
etc etc
I just want to return those values to another array
@count = (1 2 3 5 etc );
Any suggestions?