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

Magics collided. Happens. Using "$doc" instead of $doc you make a copy.

Replies are listed 'Best First'.
Re^6: XML::Writer oddness
by TedHopp (Novice) on Feb 25, 2010 at 20:03 UTC
    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.