in reply to extract uniques and sort
Here's what I ended up with for extracting uniques and sorting. I know it can be further simplified, but my non-programmer brain can somewhat grok it as is. Thanks again, all!
cheers,
ybiC
cheers,
ybiC
#!/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 |
In Section
Seekers of Perl Wisdom