#!/usr/local/bin/perl %dictionary = (); while(<>) { chomp; $dictionary{$_}++; } print "Please enter your letters: \n"; $input = ; chomp $input; foreach (split//, $input) { $letters{$_}++; } foreach (sort keys %dictionary) { my @word = split//; my %hash = %letters; my $flag = 0; foreach (@word) { if( ! exists $hash{$_} ) { $flag++; next; } if( $hash{$_} <= 0) { $flag++; next; } $hash{$_}--; } if($flag == 0 && $#word > 0) { print "@word\n"; } }