in reply to Getting rid of duplicates

Hello,

You may want to use hashes.

This is untested.
my %store; foreach (<DATA>) { chomp; $store{$_} = 1; } print join ",", keys %store; __DATA__ 1236 3232 1236 4323 4323
Something like that may work for you.

rlb3

Replies are listed 'Best First'.
Re^2: Getting rid of duplicates
by JediWizard (Deacon) on Sep 29, 2004 at 14:28 UTC

    I have a utility function I often use for this sort of thing. See Below:

    my(@numbers) = <DATA>; chomp @number; print join("\n", uniqStrings(@numbers)); sub uniqStrings { my %temp = (); @temp{@_} = (); return keys %temp; } __DATA__ 1236 3232 1236 4323 4323

    That will actually run a little faster because the method used to remove duplicate numbers is pretty well optimized. Hope that helps.

    May the Force be with you