#!/usr/bin/perl # Program to determine all possible orderings of an input word. Mathematically, this is # the list of all permutations (order is significant) of (n) letters chosen from a list # of (m) items. Calculating the number of persumations is done by this formula: # # count = n! where (n) is the sample size, and m is the pool size # ------- # (m-n)! # # Since 0! = 1, there are n! ways to choose the order of the letters is a word of n letters. # use Sterling::Process; use Sterling::Anagrams; %Config = ( "word" => "", ); &parse_form; # Determine the anagrams of the word specified # @anagrams = &get_anagrams( $Config{"word"} ); @anagrams = &get_anagrams( "a crumb cake leaper" ); # Show the results print "\n--------------------------------------\n"; print "The " . ( $#anagrams + 1 ) . " anagrams of the word \"" . $Config{"word"} . "\"\n"; print "--------------------------------------\n"; for $string ( sort @anagrams ) { print "$string \n"; } print "\n--------------------------------------\n"; print "The " . ( $#anagrams + 1 ) . " anagrams of the word \"" . $Config{"word"} . "\"\n"; print "--------------------------------------\n";