$find = Swish->new(
"'", # ignore beginning
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'",
"'", # ignore ending
'breath every',
5, # words to highlight BEFORE
5, # words to highlight AFTER
);
de>
With a call-back function of:
$find->stream(\*DATA, sub { " ... $_[1]<b>$_[2]</b>$_[3] ..." });
while (my $t = $find->match) { print "[[$t]]\n" }
And I get this result:
keywords are: <breath> <every>
[[ ... With <b>every</b> form you come
You surprise ...]]
[[ ... me, hypnotize me << shouldn't be a break here
With <b>every</b> ...]]
[[ ... <b>breath</b> I take << or here
You're depriving, suffocating ...]]
[[, choking << here's the rest of the text?
Now the time has come when I tell myself
There's nothing more I can take
Then you show me
Does it matter right now
If I'm already numb
That's what you do to control me
]]
It's tough to realize when
words match near each other and to then print out a complete line of text.
In other words, I'm looking for this output:
With <b>every</b> form you come ...
hypnotize me
With <b>every</b> <b>breath</b> I take
You're ...
So the code realizes that "every" and "breath" are near each
other so not to print out words on either side twice.
Well, I'll have to work through it on Monday.
Thanks,
|