in reply to Writing output to a scalar with XML::Writer

you need
my $writer = new XML::Writer(OUTPUT => \$output);
which passes a reference to the constructor.
$output = \"";
creates a reference to a literal string. So that won't work. Btw, next time tell us the error message. Because the error message is god.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Writing output to a scalar with XML::Writer
by longliveAJ (Acolyte) on Feb 15, 2006 at 20:05 UTC
    Holli, that doesnt work. Still get the following error message
    Can't call method "print" on unblessed reference at /usr/opt/perl/5.8. +5/lib/XML/Writer.pm line 116. at /usr/opt/perl/5.8.5/lib/XML/Writer.pm line 116 XML::Writer::__ANON__[/usr/opt/perl/5.8.5/lib/XML/Writer.pm:12 +5] called at /usr/opt/perl/5.8.5/lib/XML/Writer.pm line 133 XML::Writer::__ANON__[/usr/opt/perl/5.8.5/lib/XML/Writer.pm:13 +5] called at /usr/opt/perl/5.8.5/lib/XML/Writer.pm line 476 XML::Writer::xmlDecl('XML::Writer=HASH(0xd6dbe0)') called at g +en_activity.pl line 150 main::gen_blob('HASH(0xd2edac)') called at gen_activity.pl lin +e 115

    Below is my code
    my $output; # XML Writers object 147 my $xmlObj = new XML::Writer(OUTPUT=> \$output, NEWLINES=>0) +; 148 149 # Start XML file with the line <xml version = "1.0 150 $xmlObj->xmlDecl();

      What does print $XML::Writer::VERSION print?
      What does print ref \$output print?

        $XML::Writer::VERSION - 0.520

        print ref \$output
        This will print SCALAR