I have a lengthy string in a perl variable which has more than 500 words.
$mytext = "This text goes on and on and on........";
Basically, this lengthy string can contain anything and everything including all kinds of special characters. It can include special characters (like apostrophes - it's a division of cleo's business), numbers (like - incorporated on August 2, 2001), commas, semicolons and apostrophe's (like - through its different divisions, the business's earnings), special characters (like '&', single and double quotes)
My requirement is to extract a specific number of words (not characters) from the start of the string. For example, I may need to pick the first 200 words.
I know that there is a builtin substr function:
substr($mytext, $start, $length)
but it extracts the number of characters.
How can I extract the number of words instead?