Here's a bit of code you might want to bat around a bit. This is a perl script to accept a script from the user and check all permutations of that script to see how many words, if any, can be made from the letters supplied.
Slice away: #!/usr/bin/perl use List::Util qw(shuffle); use Math::BigInt; use Math::Combinatorics; #use Algorithm::Combinatorics qw(combinations); #anagrep_comb.pl accepts letters from the user and then scrambles the letters to form all words possible from the input my @f = ""; open(F,"/usr/share/dict/american-english"); @list=<F>;close F; print "letters?"; my $this = <>; chomp $this; my $thiso = $this;#save original input $len = length($this); $comb = fac($len); print "You've input $this ($len characters, $comb combinations)\n"; #find the combinations my @n = split(//,$this); my $combinat = Math::Combinatorics->new(count => $len, data => [@n], ); print "checking $comb permutations of length $len from: ".join(" ",@n)."\n"; print "------------------------".("--" x scalar(@n))."\n"; while(my @permu = $combinat->next_permutation){ print "."; $this = join(' ',@permu); $this =~ s/ //g;#remove spaces inserted by split $check = "^$this\n";#change $this so we grep for lines that contain only $this @f = ""; @f=grep /$check/,@list; if (@f) { print "\n\n<< $this >> is a word.\n\n";} } print "\n\nThat's all folks!\n"; print"\n\n"; sub fac { my ($m) = @_; return 1 if($m <=1 ); return $m*fac($m-1); } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/