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


In reply to Re: Pattern matching question by davido
in thread Pattern matching question by perlsen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.