the/article book/noun he/pronoun is/verb ill/adjective #### the book article noun he is ill pronoun verb adjective #### open(MYFILE, ">output.txt") or die ("can not write to file\n"); open(INFILE, "input.txt") or die ("can not open file\n"); $w = "[a-z]"; while($line = ) { while($line =~ /(\d+)/g) { push(@nums, $1); } while($line =~ /($w+)/g) { push(@words, $1); } } push(@nums, @words); foreach $token(@nums) { print(MYFILE "$token "); }