There are three approaches to this problem:
# Instead of >perl -w myscript.pl -some -command -line # you invoke it as >perl -w myscript.pl -some -command -line >output.xml
BEGIN { my $outfile = 'output.xml'; close STDOUT; open STDOUT, ">", $outfile or die "Couldn't create '$outfile': $!"; };
# Instead of sub frobnitz { my ($input) = @_; if ($input =~ /foo/) { $input =~ s!foo!frobnitz!g; print $input; }; }; # write: sub frobnitz { my ($input) = @_; if ($input =~ /foo/) { $input =~ s!foo!frobnitz!g; return "<foo>$input</foo>" } else { return $input; }; }; # ... print frobnitz($in);
In reply to Re: Sending output to an xml file
by Corion
in thread Sending output to an xml file
by tito1981
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |