Really? That seems like a better alternative than writing your own dispatch table? Even using the built in handlers, you still have to write the subroutines themselves. I guess from an abstraction perspective it is appealing but consider my existing code looks like:
my $twig = XML::Twig->new();
while (<$fh>) {
$twig->parse($_);
# ...
}
Will now need to look like:
while (<$fh>) {
my $twig = XML::Twig->new($data_struct);
$twig->parse($_);
# ...
}
I have no idea the extent of the performance overhead but it is probably less than the alternative:
my $twig = XML::Twig->new($data_struct);
while (<$fh>) {
$twig->parse($_);
# ...
my $copy = deep_copy($data_struct);
$data_struct = clear_structure($data_struct);
}
I am not saying it is a bad idea - it just doesn't feel clean to me.
|