Hi, $str is a variable, maybe you meant substr?
Try this:
( See perlrequick, perlretut )$ perl -Mstrict -wE 'my $str = "mary had a little lamb"; say for ($st +r =~ /(\S+)/g)[0..2]'
Hope this helps!
In reply to Re: Extract a specific number of words from a string
by 1nickt
in thread Extract a specific number of words from a string
by author104
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |