$string = "now is the time for all good men to come to the aid of their country while the gratuitously extralongwordwithmorethantwentycharactersexdtendson and on."; grep { push(@arr,substr($_,0,19)) } split (" ",$string); print join("\n",@arr);