CODE
sub get_TagData {
if ($file[$x]=~/(<.*>)/) {
$_=$file[$x];
/(<\/w:t>)(.*?)(<w:t>)/ig; #the group of formatting tags begins with "</w:t>" and ends with "<w:t>"; [b]this is line #4[/b]
$tagset=$1.$2.$3;
push (@tagset, $tagset);
}
}
if ($file[$x]=~/(<.*>)/) {
$_=$file[$x];
/(<\/w:t>)(.*?)(<w:t>)/ig; #the group of formatting tags begins with "</w:t>" and ends with "<w:t>"; [b]this is line #4[/b]
$tagset=$1.$2.$3;
push (@tagset, $tagset);
}
}
The XML document I'm working with is made up of two lines (one with the filename, and one with the content), which are read into two array elements in the array @file. Initially, line 4 contained
CODE
/(<\/w:t>)(.*)(<w:t>)/i;
, but in addition to giving me all of the tags I was looking for, it also gave me all of the text of the XML document in between the first and last tag sets. I don't mind having the text in there, but the problem was that the program would then push all of the tag sets into one array element, at which point I could not deal with it. I then added the ? operator to the center search element (as it is in the fully shown subroutine above). This solved the problem of having multiple tag sets in the array, but I then ended up with only one element in the array. I tried adding g operator to get it to search globally, but it wouldn't. Is there any way to take a string (since that's what I'm essentially working with) and return multiple instances of a pattern? I appreciate any help.