in reply to Re: XML::Parser Style=>Subs and undefined subroutines
in thread XML::Parser Style=>Subs and undefined subroutines
Check out XML::Parser::Style::Subs within the Start and End subs, the following is executed:
my $sub = $expat->{Pkg} . "::$tag"; eval { &$sub($expat, $tag, @_) };
All that happens is the dies are captured into $@ and the Start and/or End subs return undef.
Update: Btw, for the behavior you seek, try this instead:
package XML::Parser::Style::DieSubs; sub Start { no strict 'refs'; my $expat = shift; my $tag = shift; my $sub = $expat->{Pkg} . "::$tag"; $sub->($expat,$tag,@_) if defined &{$sub}; } sub End { no strict 'refs'; my $expat = shift; my $tag = shift; my $sub = $expat->{Pkg} . "::${tag}_"; $sub->($expat,$tag) if defined &{$sub}; } 1;
It doesn't die if the sub doesn't exist, though. It does, however, allow your subroutines to die. If you wish for it to die if the subroutines don't exist, this is fairly trivial given the above code.
Hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|