in reply to Re: Convert XML To Perl Data Structures Using XML::Twig
in thread Convert XML To Perl Data Structures Using XML::Twig

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.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Convert XML To Perl Data Structures Using XML::Twig
by anonymized user 468275 (Curate) on May 24, 2011 at 16:29 UTC
    Hmm I guess it's just a question of personal style what "clean" is. But I do actually agree with the idea of the dispatch table, it's just that I would put that in the instance variable of my own class, sorry if that wasn't clear in my post. But I would need to see more of the code to have a really good idea what "clean" is relative to it, without going against your style.

    One world, one people