#!/usr/bin/perl -w use strict; my @words; my %list; unless ($ARGV[1]){ print "Usage is oneword infile outfile\n"; exit; } open (WORDLIST, "$ARGV[0]")||die "Could not open file $!"; open (OUTFILE, ">$ARGV[1]")||die "Could not open file $!"; while (){push (@words => $_)} foreach (@words){$list{$_}=$list{$_}} #this works because if the hash key #exists already it is replaced! foreach (keys %list){print OUTFILE;}