$ perl -Mstrict -wE 'my $str = "mary had a little lamb"; say for ($str =~ /(\S+)/g)[0..2]'