in reply to Extract a specific number of words from a string
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!
|
|---|