in reply to Using XML::Writer, how can I output to a file AND to the console?
Open a file handle on a string:
use strict; use warnings; use XML::Writer; my $outputStr; open my $output, '>', \$outputStr; my $writer = new XML::Writer(OUTPUT => $output); $writer->startTag("greeting", "class" => "simple"); $writer->characters("Hello, world!"); $writer->endTag("greeting"); $writer->end(); close $output; print $outputStr;
Prints:
<greeting class="simple">Hello, world!</greeting>
Having captured the output to a string you can print where ever you want and as many times as you want.
Update helps to copy and paste the right stuff!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using XML::Writer, how can I output to a file AND to the console?
by envinyater (Initiate) on Dec 14, 2012 at 14:37 UTC |