in reply to Passing additional arguments to XML::Twig handlers

If you want only constant args, you can fall back on closures:
my $greeting = "hi"; my $my_s = sub { my ($twig, $section) = @_; print $greeting || "Hello" , ", ", $section->text(), "!\n"; }

You can then pass the closure in $my_s just like a normal reference to a sub.

Replies are listed 'Best First'.
Re^2: Passing additional arguments to XML::Twig handlers
by pseudomonas (Monk) on Jan 29, 2008 at 14:47 UTC
    The args change from parse to parse, unfortunately. Closures are something I need to get more used to in general, though - thanks!