[please don't top post - reordered to proper format] On Wed, 04 Feb 2004
11:05:06 -0600, Ram wrote:
> "Gunnar Hjalmarsson" <> wrote in message
> news:bvp3d5$ujeo2$...
>> Ram wrote:
>> > How do I search for just the ordsts start(<ordsts>) and end
>> > tags(</ordsts>) and the data between them, and get just the last
>> > matched one.
>>
>> Assuming the data is in $_:
>>
>> my ($lastmatch) = /.*(<ordsts>.*<\/ordsts>).*/s;
>>
>> > Also would need an idea of how to get the last two matches.
>>
>> I leave that as an excercise to you. 
>>
>> > Thanks for the pointers.
>>
>> http://www.perldoc.com/perl5.8.0/pod/perlre.html
>>
>> --
>> Gunnar Hjalmarsson
>> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>>
> This string does not match if <ordsts> and </ordsts> has child tags
> spread across multiple lines.
>
> If I stick this to the end of file, it does not match: <ordsts>
> <gname>
> </gname>
> </ordsts>
> But it matches:
> <ordsts> <gname> </gname> </ordsts>
>
> For my case, it should match the both, including the child tags.
I'd follow the suggestion offered by Chris Olive - use an XML module to
parse your data. It will save you lots of time and effort - and reduce
the amount of "mistakes" made in parsing. Right now, if someone changes
the format of the file, you'll have to go through a similar type exercise
again in the future.
Again, it's just a suggestion
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL.
http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
You never know how many friends you have until you rent a house
<on the beach.