Hi Monks!
I have an xml file where I am trying to read the number located between <customer_id> and </customer_id>. I can't use substr beause the position will not be consistent. I was thinking of split but after doing some research I am not sure it will be possible with it. I was then looking into a regrex exp but i am not too proficient in it and somewhat lost. The length of the number will be consistent though (7).
Could you please help me figure out how I could extract the number between the above mentioned tabs?
eg. <customer_id>1234567</customer_id> how to get 1234567?
Thanks in advance!

Thanks for all the input guys! i ended up using the following:

if($_ =~ /<Customer_ID>(.*)<\/Customer_ID>/) { my $c = $1; }


In reply to Grabbing specific string from a line by sowais

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.