|There's more than one way to do things|
best practice when using XML::Parser and strict.by reasonablekeith (Deacon)
|on Feb 28, 2005 at 11:36 UTC||Need Help??|
reasonablekeith has asked for the
wisdom of the Perl Monks concerning the following question:
Servers are down this morning, which gives me time to seek advice re best practice when using XML::Parser and strict. :-)
Basically, when writing event driven parsing scripts, I always find that I need to share some variables between the handlers. My question is, whatís the best way to do this? I offer a simple example, which prints the node elements neatly indented.
Iím quite happy with this, as I donít have any global variables (I know any previous $indent value will be temporarily trashed, but I can cope with that), Iíve got a shared variable (dynamically scoped) to use in my handlers, and my handlers explicitly pick up this shared variable. My main concern is that Iíve had to use Ďno strict subsí define $indent, which makes me think Iíve done a bad thing, and that perhaps thereís a neater way of doing this, without having to turn off strict.