http://qs321.pair.com?node_id=169934


in reply to Problem with a Ref to a global variable while using XML::Parser

I think you answered your own question (Effectively deal with the global hash variable (by redefining it?)). Can't you just let the last thing on @stories be the hash reference and not even deal with the hash?
sub StartTag { # Other stuff okay... but add.. if ($tag eq 'story') { push @stories, {}; } } # This subroutine is mostly superflous now I think... sub EndTag { pop @curr; } sub Text { unless ($curr[-1] eq 'story') { $stories[-1]->{$curr[-1]} = $_; } }
And that might do it. (untested)
  • Comment on Re: Problem with a Ref to a global variable while using XML::Parser
  • Download Code

Replies are listed 'Best First'.
Re: Re: Problem with a Ref to a global variable while using XML::Parser
by beamsack (Scribe) on May 29, 2002 at 03:39 UTC
    And that did it clintp!
    The script now works as expected.
    And thanks to crazyinsomniac for the recommendations.