in reply to Re^3: XML::Writer oddness
in thread XML::Writer oddness

So don't be afraid to use it as a string.

Heh. Well, doing just that is what led to the problem with gzip. :-)

Replies are listed 'Best First'.
Re^5: XML::Writer oddness
by ikegami (Patriarch) on Feb 25, 2010 at 04:48 UTC
    Magics collided. Happens. Using "$doc" instead of $doc you make a copy.
      Indeed it does. That leads me to wander off topic. I had tried $doc = "$doc";, which was close but does not work. Even this does not work:
      my $copy = $doc; undef *doc; $doc = $copy;
      After that, $doc is still a blessed object (although $copy isn't). From this, I conclude that I don't understand symbol tables. Why doesn't it work to undef everything about $doc? (For that matter, why isn't $copy a blessed object?) Is there a way to "unbless" $doc and to remove its object flag after it has been mucked with by XML::Writer?
        After that, $doc is still a blessed object (although $copy isn't).

        In the OP, you have $doc declared as my variable, so fiddling around with the symbol table doesn't do anything to my $doc.

        my has Perl use a lexically scoped variable instead of global package variables. Freeing the similar named package variable does not affect the lexical.

        There doesn't seem to be anyway to unbless in Perl's API.