in reply to Re^2: While two conditions
in thread While two conditions
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: While two conditions
by welle (Beadle) on May 01, 2012 at 14:10 UTC | |
by GrandFather (Saint) on May 01, 2012 at 20:56 UTC | |
by welle (Beadle) on May 02, 2012 at 12:57 UTC |