author104 has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I am looking to extract a specific number of words form a string imported from a text file. This is a web script.
Example.
Text file contains "Mary had a little lamb"
x=3
I then want to pull the first three words, "Mary had a " and display it on a web page.
What I am asking is similar to the $str function, but with words, instead of string length.
How do I do this?
Thanks in advance
Author104
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extract a specific number of words from a string
by hippo (Archbishop) on Nov 25, 2017 at 16:19 UTC | |
|
Re: Extract a specific number of words from a string
by AnomalousMonk (Archbishop) on Nov 25, 2017 at 16:38 UTC | |
|
Re: Extract a specific number of words from a string
by 1nickt (Canon) on Nov 25, 2017 at 16:09 UTC | |
|
Re: Extract a specific number of words from a string
by johngg (Canon) on Nov 25, 2017 at 23:09 UTC |