I am taking notes of some of the advanced perl tricks used in perl.
1.to get all the matched items using the /g flag,
2.to get the word count,
3.The built-in pos() operator returns the match position for the string we give it (or $_ by default).
1 2 3 4
4.To anchor our next match exactly where we left off the last time, we can use the \G anchor. It’s just like the beginning of string anchor \A, except for where \G anchors at the current match position. If our match fails, Perl resets pos() and we start at the beginning of the string.