#!/usr/bin/perl -w $infile=; chomp($infile); open(FIN, "< $infile") or die "failed\n"; while($line=){ chomp($line); $element=$line; $hash{$element}[0]=0; } close(FIN); open(FOUT, "> count_freqs"); open(FIN, "< $infile") or die "failed\n"; while($line=){ chomp($line); $element=$line; $hash{$element}[0]++; } close(FIN); @array_elements=sort keys %hash; foreach $element (@array_elements){ print FOUT "$element\t$hash{$element}[0]\n"; } close(FOUT);