It's hard to tell exactly what you want to do, but a first guess is that my original suggestion was exactly on the money. Consider:
use strict; use warnings; use Lingua::Concordance; my $text = <<TEXT; Oldfield's career began fairly early, playing <1> acoustic guitar in l +ocal folk clubs. At this time, he already had two fifteen-minute instrumental pi +eces in which he would "go through all <2>sorts of moods", precursors to his l +andmark 1970s' compositions. In his early teens, Oldfield was involved in a 'b +eat group' <3>playing Shadows-style music (he has often cited Hank Marvin as a ma +jor influence, and would later cover The Shadows' song "Wonderful Land"). TEXT my $query = 'in'; my $concordance = Lingua::Concordance->new (); $concordance->radius(25); $concordance->text($text); $concordance->query($query); my @matches = $concordance->lines(); my @pairs; for my $match (@matches) { while ($match =~ /<(\d+)>.*?$query/g) { push @pairs, map {[$_, $match]} $1 if $-[0] < $concordance->r +adius(); } } print "$_->[0]: $_->[1]\n" for @pairs;
Prints:
1: ng <1> acoustic guitar in local folk clubs. At thi 3: a 'beat group' <3>playing Shadows-style music (he
In reply to Re^3: While two conditions
by GrandFather
in thread While two conditions
by welle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |