in reply to substring extraction

Your description doesn't completely tally with your code. If the file contains a single long string, then your while loop will only iterate once. However, to print out all, whitespace delimited words that either match or contain a given search term, you could use:

$string = 'this is a really long string (no really, it is!) that conta +ins a whitespace delimited word'; print $1 while $string =~ m[(\b\S*limit\S*\b)]gi;; ## All words, case +insensitive. delimited

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.