$/ = ".\n"; # Sets a special ``chunk-mode''; chunks end with aperiod-newline combination
while (<>)
{
next unless s{# (regexstarts here)
### Need to match oneword:
\b # Start of word . . . .
( [a-z]+ ) # Grab word, filling $1 (and \1).
### Now need to allow anynumber of spaces and/or <TAGS>
( # Save what intervenes to $2.
(?: # (Non-capturing parens for grouping the alternation)
\s # Whitespace (includes newline, which is good).
| # -or-
<[^>]+> # Item like <TAG>.
)+ # Need at least one of the above, but allowmore.
)
### Now match the firstword again:
(\1\b) # \b ensures not embedded. This copy saved to$3.
#(regex ends here)
}
# Above is the regex. The replacement string isbelow, followed by the modifiers, /i, /g, and /x
{\e[7m$1\e[m$2\e[7m$3\e[m}igx;
s/^(?:[^\e]*\n)+//mg; # Remove any unmarked lines.
s/^/$ARGV:/mg; # Ensure lines begin with filename.
print;
}