XML::Writer blesses $doc for some reason. I presume IO::Compress::gzip checks for that even though it would have no effect in this case. Copying $doc doesn't copy the blessing.
use strict; use warnings; use Devel::Peek qw( Dump ); use Scalar::Util qw( blessed ); use XML::Writer qw( ); my $writer = new XML::Writer(OUTPUT => \my $doc); $writer->startTag("root"); $writer->startTag("foo"); $writer->endTag("foo"); $writer->endTag("root"); $writer->end(); Dump $doc; print(blessed(\$doc)?1:0, "\n"); # 1 my $copy = $doc; Dump $copy; print(blessed(\$copy)?1:0, "\n"); # 0
SV = PVMG(0x18c5614) at 0x182a39c REFCNT = 2 FLAGS = (PADMY,OBJECT,POK,pPOK) IV = 0 NV = 0 PV = 0x1922fbc "<root><foo></foo></root>\n"\0 CUR = 25 LEN = 28 STASH = 0x19154b4 "XML::Writer::_String" 1 SV = PVMG(0x18c5654) at 0x1915784 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) IV = 0 NV = 0 PV = 0x1925184 "<root><foo></foo></root>\n"\0 CUR = 25 LEN = 28 0
In reply to Re: XML::Writer oddness
by ikegami
in thread XML::Writer oddness
by TedHopp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |