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
In reply to Re: Accessing outside variable using XML::Twig
by Joost
in thread Accessing outside variable using XML::Twig
by KarateCowboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |