open(OUTPUT,">>${len}.words"); while(<>){ chomp($_); $len = length($_); print OUTPUT "$_\n"; } close(OUTPUT);