in reply to Comparison problem

It's not clear to me what you're doing with $x -- are you using it as a symbolic ref? -- but the common way to construct a unique set is to use a hash. If $x were a hashref instead of an arrayref, you could simply use keys %$x to get the list -- though it would not be in original insertion order.

If you need the arrayref (or the ordering) you could keep a separate hash to track which values have already been inserted. That would look something like:

push @$x, $digit{$nu} unless $seen{$digit{$nu}};
Or you could use Tie::Hash::Sorted to get the same effect from a hash.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Comparison problem
by emav (Pilgrim) on Oct 27, 2004 at 22:16 UTC
    Indeed, insertion order is important in my code but $x is simply used as an abbreviation for $digit{$nu}, $digit{$nl} and the other hashes I've included in my code. It facilitates cut'n'paste... ;-)

    Thanks for the code snippet, though. I'll work on it...