#!/usr/bin/perl -wT $ENV{'PATH'} = ""; use strict; my $word = defined($_=shift) ? $_ : die "usage: $0 \n"; chomp($word); ($word) = $word =~ /^(\w+)$/ or die 'Bad User!'; my @chars = split //, $word; my $speller ="spelled"; sub spelled { my $word = shift; my $out=`$speller $word`; chomp($out); if ( length($out) > 0 ) { print "[$out]\n"; } } sub swap { my $i = shift; my $j = shift; my $A = shift; # ref to array my $tmp = @{$A}[$i]; @{$A}[$i] = @{$A}[$j]; @{$A}[$j] = $tmp; } sub permute { my $i = shift; my $n = shift; my $T = shift; #ref to array if ( $i == $n ) { my $word = join( "", @{$T} ); spelled( $word ); } else { for my $j ( $i..$n) { swap( $i-1, $j-1, $T ); permute( $i+1, $n, $T ); swap( $i-1, $j-1, $T ); } } } permute (1,$#chars+1,\@chars); #### $ cat spelled #!/bin/sh ASPELL=/usr/bin/aspell GREP=/usr/bin/grep EGREP=/usr/bin/egrep for i in $* do correct=`echo $i | $ASPELL -a | $GREP -v '^@' | $GREP -v '^&' | $EGREP -v '^$'` if [ ! -z "$correct" ] then echo "$i" fi done #### $ jumble.pl cat [cat] [act]