in reply to XML::Twig newbie question
What I can't figure out is, how to pass the name in $file to the event handler, or conversely, how to associate the found attribute back to the $file. I'm probably missing something obvious, but can't puzzle it out. Any suggestions would be greatly appreciated.
You're missing closures, examples in XML::Twig traversing tree and storing in an array, XML::Twig n00b, Tutorials: Closure on Closures
for my $file ( ... ){ my $filename = $file; my %filnameKeyref; my $topicref = sub { ... $filenameKeyref{ $filename }; return; }; my $twig= XML::Twig->new( ... => $topicref ); $twig->...; }
Although you ought to write that as
for my $file ( ... ){ my $complexAssociations = FooAssoc( $file ); WalkAndTalk( $complexAssociations ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Twig newbie question
by Jenda (Abbot) on Sep 18, 2012 at 07:15 UTC | |
by Anonymous Monk on Sep 18, 2012 at 07:31 UTC | |
by Jenda (Abbot) on Sep 18, 2012 at 10:57 UTC | |
by slugger415 (Monk) on Sep 18, 2012 at 15:50 UTC | |
by Jenda (Abbot) on Sep 18, 2012 at 19:34 UTC | |
|
Re^2: XML::Twig newbie question
by slugger415 (Monk) on Sep 18, 2012 at 15:52 UTC |