in reply to Problem with Regex
Hi there,
I guess this is what you need:
my $str = join(" ",<$file>); print $1 while $str =~ /<$tagname>(.*)<\/$tagname>/msg;
I think you are missing two things: 1. Multiline matching (for example the contents of "revision" spans several lines). See regexp flags below. 2. In addition, you need to slurp the contents of your file first. Otherwise you'll get empty results when you try to get the contents of elements like "revision".
In any case, IMHO the best thing to do always is to use standard/well known libraries. Try XML::XPath. XPath is actually not that hard (the brief tutorial at http://www.w3schools.com/ may suffice).
Hope this helps anyway, Juampa
|
|---|