while(){ for my $myword (split(/\s+/)){ #do stuff } #There's a newline now }