For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Backtracking question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Backtracking question
N. Ganesh Babu

2005-06-07, 8:56 am

Dear All,

<lt=c24>PRL IJB PRL CHA <refauth><fname>K.</fname>
<middlename>M.</middlename> <surname>Cuomo</surname></refauth> and
<refauth><fname>A.</fname> <middlename>V.</middlename>
<surname>Oppenheim</surname></refauth>, <jtitle>Phys. Rev.
Lett.</jtitle> <B><volume>71</volume>,</B> <pages>65</pages>
(<date>1993</date> ); <refauth><fname>L.</fname>
<surname>Kocarev</surname></refauth>, <refauth><fname>K.</fname>
<middlename>S.</middlename> <surname>Halle</surname></refauth>,
<refauth><fname>K.</fname> <surname>Eckert</surname></refauth>,
<refauth><fname>L.</fname> <middlename>O.</middlename>
<surname>Chua</surname></refauth>, and <refauth><fname>U.</fname>
<surname>Parlitz</surname></refauth>, <jtitle>Int. J. Bifurcation
Chaos Appl. Sci. Eng.</jtitle> <B><volume>2</volume>,</B>
<pages>973</pages> (<date>1992</date> ); <refauth><fname>L.</fname>
<surname>Kocarev</surname></refauth> and <refauth><fname>U.</fname>
<surname>Parlitz</surname></refauth>, <jtitle>Phys. Rev.
Lett.</jtitle> <B><volume>74</volume>,</B> <pages>5028</pages>
(<date>1995</date> ); <refauth><fname>N.</fname>
<middlename>F.</middlename> <surname>Rulkov</surname></refauth>,
<jtitle>Chaos</jtitle> <B><volume>6</volume>,</B> <pages>262</pages>
(<date>1996</date> ).</lt>


How to backtrack the below pairs of information from the above line.
the number of pairs/line may chage from a range of 1 to 5


PRL <jtitle>Phys. Rev. Lett.</jtitle>
IJB <jtitle>Int. J. Bifurcation Chaos Appl. Sci. Eng.</jtitle>
PRL <jtitle>Phys. Rev. Lett.</jtitle> CHB <jtitle>Chaos</jtitle>

Regards,
Ganesh



Thomas Bätzler

2005-06-07, 8:56 am

N. Ganesh Babu <ganesh@ald.apexcovantage.com> wrote:
> Dear All,
>
> <lt=c24>PRL IJB PRL CHA <refauth><fname>K.</fname>
> <middlename>M.</middlename>

[...]

I'm having a bad case of deja vu with this...

> How to backtrack the below pairs of information from the above line.
> the number of pairs/line may chage from a range of 1 to 5


I'd say parsing with XML::Parser could help you getting
the data into a manageable shape, although I'd suggest
you fix the markup first:

#!/usr/bin/perl -w

use strict;
use XML::Parser;
use Data::Dumper;

my $xml = '<bibliography chapter="24"><publication short="PRL" title="Phys.
Rev. Lett." volume="71" pages="65" year="1993"><author fname="K."
middle="M." surname="Cuomo" /><author fname="A." middle="V."
surname="Oppenheim" /></publication></bibliography>';

my $p = new XML::Parser(Style => 'Tree');

print Dumper $p->parse($xml);

__END__

HTH,
Thomas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com