in reply to Re: Printing a Tag content
in thread Printing a Tag content

Okies there is one more for the TIMTOWTDI and the golf fans.
This is probably bad style but see yourself.
#!/usr/bin/perl -w print ("Enter the word to search >> "); chomp ($word = <STDIN>); { local $/=undef; print grep { $_ =~ $word } <DATA> =~ m!(<MS_\d+>.*?</MS_\d+>)!gs; } __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>