in reply to Accessing outside variable using XML::Twig
Note that the anonymous sub closes over the $self in the outer scope. Closures are extremely useful; you owe it to yourself to read up on them.$self->{twig} = new XML::Twig(twig_handlers => { tag => sub { my ($twig,$tag) = @_; + $self->tagHandler($tag) +; } });
here's an introductionary article on closures.
updated formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing outside variable using XML::Twig
by KarateCowboy (Initiate) on Jan 31, 2008 at 20:45 UTC |