gzayzay has asked for the wisdom of the Perl Monks concerning the following question:
print "\nEnter your words (separated by spaces): >> "; chomp(my $line = <STDIN>); my @words = split /\s+/, $line; for($i = 0; $i <= ($#words-1); $i++) { for($j = $i+1; $j <= $#words; $j++) { print "========================================\n"; print "\t", ucfirst(@words[$i]),"\t", ucfirst(@words[$j]),"\n"; print "========================================\n"; local $/=undef; print grep{!/(@words[$i,$j])/}<DATA> =~ m!(<MS_\d+>.*?</MS_\d+ +>)!gs if /(@words[$i,$j])/; } } __DATA__ <MS_1> <loc>c:\data\cat.xml</loc> <words>dog, cat, fish, bird</words> </MS_1> <MS_2> <loc>c:\data\cow.xml</loc> <words>dog, cat, fish, bird, cow, goat</words> </MS_2> <MS_3> <loc>c:\data\snake.xml</loc> <words>dog, cat, fish, bird, snake, orange</words> </MS_3>
Thanks,
gzayzay
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching combination of words in a tag
by davidrw (Prior) on Apr 17, 2006 at 15:15 UTC |