> That will work, but only if the search terms appear in document in the > same order as they appear in the query. (This appears to be the case > with the hipdig solution as well. Correct me if I'm wrong, of > course.) The search terms I'm looking for could appear in the target > document in any order. Perhaps I could have made that clearer. Okay, > I *could* have made that clearer.
Tricky but doable. #!/usr/bin/perl # author: kevin d. clark use warnings; use strict; my %seen; my $r; undef $/; while (defined($_=<>)) { undef $^N; print "Filename: $ARGV\n$&\n" if (/ ((??{ $r = ""; $seen{$^N}++ if (defined($^N)); $r .= "weapons|" if (!defined($seen{"weapons"})); $r .= "mass|" if (!defined($seen{"mass"})); $r .= "distraction" if (!defined($seen{"distraction"})); $r; })) .{0,100}? # 0-100 characters of any random cruft ((??{ $r = ""; $seen{$^N}++ if (defined($^N)); $r .= "weapons|" if (!defined($seen{"weapons"})); $r .= "mass|" if (!defined($seen{"mass"})); $r .= "distraction" if (!defined($seen{"distraction"})); $r; })) .{0,100}? # 0-100 characters of any random cruft ((??{ $r = ""; $seen{$^N}++ if (defined($^N)); $r .= "weapons|" if (!defined($seen{"weapons"})); $r .= "mass|" if (!defined($seen{"mass"})); $r .= "distraction" if (!defined($seen{"distraction"})); $r; })) /xs) } __END__ I could generalize this and all, but I am busy. Basically, the gist of this code is that it generates the regexp to match while the regexp engine is doing the matching. Just another Perl hacker, --kevin -- GnuPG ID: B280F24E God, I loved that Pontiac. alumni.unh.edu!kdc -- Tom Waits http://kdc-blog.blogspot.com/ _______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/