#! perl -sw use vars qw($debug); use strict; local $\=$/; sub IsWord { no warnings; return if not @_ or length == 1; my ($word, $first, $c2n3) = $_[0] =~ /^((.)(..?)?.*)$/; $c2n3 = substr( $c2n3 . '__', 0, 2); local $_ = do{ local (@ARGV,$/) = "c:/test/words/$first/$c2n3"; <> }; return /^$word$/im; } while() { chomp(my $phrase = $_); my $c= - length $phrase; my @words; while (length $phrase) { my $bit = substr($phrase, $c); if (IsWord($bit)) { unshift @words, $bit; $phrase = substr($phrase, 0, $c); $c = - length $phrase; } else { ++$c; last if 0 == (length($phrase)- $c); } } print "${_}may consist of the words\n@words\n"; } __END__ hudjheuhfnnvgxvbchnfhfujryyfgbch whererangesarealltherage thequickbrownfoxjumpsoverthelazydog hsdkjfhuewfklJLKSDossfdlkjaslduasl PeterPiperPickedAPeckOfPickledPepper lazinessimpatiencehubris