sowais has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grabbing specific string from a line
by choroba (Cardinal) on Mar 01, 2012 at 18:30 UTC | |
|
Re: Grabbing specific string from a line
by kcott (Archbishop) on Mar 01, 2012 at 18:23 UTC | |
|
Re: Grabbing specific string from a line
by JavaFan (Canon) on Mar 01, 2012 at 18:21 UTC | |
by CountZero (Bishop) on Mar 01, 2012 at 19:32 UTC | |
by JavaFan (Canon) on Mar 01, 2012 at 20:11 UTC | |
by CountZero (Bishop) on Mar 02, 2012 at 06:37 UTC |