in reply to Pattern matching question
What kind of markup is that? Is it XML? (if it is, XML parsers don't seem to like it). Assuming you're actually passing valid XML, this doesn't have to be a "pattern matching question"; you could just do this:
use strict; use warnings; use XML::Simple; use Data::Dumper; my $xml = <<'HERE'; <ContentItem> <TextItem> <TextItemType>03</TextItemType> <FirstPageNumber>29</FirstPageNumber> <LastPageNumber>56</LastPageNumber> <NumberOfPages>28</NumberOfPages> </TextItem> <ComponentTypeName>Chapter</ComponentTypeName> <DistinctiveTitle>The emergence of an Islamic</DistinctiveTitle> </ContentItem> <ContentItem> <TextItem> <TextItemType>03</TextItemType> <FirstPageNumber>29</FirstPageNumber> <LastPageNumber>34</LastPageNumber> <NumberOfPages>6</NumberOfPages> </TextItem> <ComponentTypeName>Chapter</ComponentTypeName> <DistinctiveTitle>The Arab Conquests</DistinctiveTitle> </ContentItem> HERE my $ref = XMLin( $xml, ForceArray => 1 ); print Dumper $ref;
This doesn't run correctly, because the data I'm sending to XMLin() isn't understood to be valid XML by XML::Simple, but if what you've shown us is just not complete, wheras what you're working with is, this would run fine, and would place the XML document into a datastructure that's being dumped by Data::Dumper.
And then the next step would be to just figure out which portion of the datastructure contains the data you want. No regexps, no guesswork. :)
Dave
|
|---|