in reply to extract uniques and sort
#!/usr/bin/perl -w use strict; my $infile = shift; my $outfile = shift; my %seen; open (IN, "<$infile") or die "Can't open $infile RO: $!"; open (OUT, ">$outfile") or die "Can't open $outfile RW: $!"; foreach my $item (<IN>) { # parse $infile into a hash and remove + duplicate keys ++$seen{$item}; } print OUT sort keys %seen; # sort keys and save to $outfile close IN or die "Cannot close $infile: $!"; close OUT or die "Cannot close $outfile: $!";
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: extract uniques and sort (thanks. 1WTDI)
by Fastolfe (Vicar) on Sep 22, 2000 at 23:57 UTC | |
by merlyn (Sage) on Sep 23, 2000 at 02:40 UTC | |
by Fastolfe (Vicar) on Sep 23, 2000 at 04:11 UTC | |
by ybiC (Prior) on Sep 23, 2000 at 00:08 UTC |