my ($oldfirst, $oldsecond) = ( '', '' ); open WORDS, '<', $ARGV[0] or die $ARGV[0] . $1 . $/; while() { chomp; next if length == 1; $_ = lc; my ($first, $second) = /^(.)(.).*/; $first = './' . $first; $second = $first . '/' . (($second eq ' ') ? '_' : $second); if ( ($first ne $oldfirst) or ($second ne $oldsecond) ) { mkdir $first if not -e $first; open SUB, '>>', $second or die $second . $! . $/; } print SUB $_, $/; ($oldfirst, $oldsecond) = ($first, $second); print "\r$second:$_ "; }