|
From: kf on 22 Feb 2006 15:55 Hi, I'm parsing some relatively complex XML files, but actually only need to access a couple of the bits of information stored with them. I thought about coding some kind of parser myself, but am fighting the urge to persevere with the XML::Parser module. So. I use XML::Parser in "Tree" mode to create a big array of arrays of arrays and then figured I could pass a reference to this array to something like this: sub FindObjByName { my $name = shift; my $ref = shift; if ($ref->[0] eq $name) { return $ref->[1]; } else { if ($ref->[0][1]) { &FindObjByName($name, $ref->[0][1]); } else { return 0; } } } But I'm having endless issues getting it to work. Any help greatly appreciated!
From: Jim Gibson on 22 Feb 2006 16:37 In article <1140641717.008936.96770(a)z14g2000cwz.googlegroups.com>, kf <jeffsnox(a)gmail.com> wrote: > Hi, > > I'm parsing some relatively complex XML files, but actually only need > to access a couple of the bits of information stored with them. > > I thought about coding some kind of parser myself, but am fighting the > urge to persevere with the XML::Parser module. > > So. I use XML::Parser in "Tree" mode to create a big array of arrays of > arrays and then figured I could pass a reference to this array to > something like this: You are better off posting a complete program rather than just a subroutine. > > sub FindObjByName > { > my $name = shift; > my $ref = shift; > > if ($ref->[0] eq $name) > { > return $ref->[1]; > } > else > { > if ($ref->[0][1]) > { > &FindObjByName($name, $ref->[0][1]); You probably want return FindObjByName($name, $ref->[0][1]); here (no ampersand needed). > } > else > { > return 0; > } > } > } > > But I'm having endless issues getting it to work. > > Any help greatly appreciated! > -- Jim Gibson Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
|
Pages: 1 Prev: perl/expect.pm manual user input Next: FAQ 4.24 How do I reverse a string? |