From: Grant M. <gr...@us...> - 2006-09-19 09:52:38
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10760/lib/XML Modified Files: Simple.pm Log Message: - automatically load IO::Handle if required to parse from lexical filehandle Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Simple.pm 19 Sep 2006 08:33:30 -0000 1.25 +++ Simple.pm 19 Sep 2006 09:52:34 -0000 1.26 @@ -546,7 +546,12 @@ if($self->{opt}->{outputfile}) { if(ref($self->{opt}->{outputfile})) { - return($self->{opt}->{outputfile}->print($xml)); + my $fh = $self->{opt}->{outputfile}; + if(UNIVERSAL::isa($fh, 'GLOB') and !UNIVERSAL::can($fh, 'print')) { + eval { require IO::Handle; }; + croak $@ if $@; + } + return($fh->print($xml)); } else { local(*OUT); @@ -2445,6 +2450,10 @@ open my $fh, '>:encoding(iso-8859-1)', $path or die "open($path): $!"; XMLout($ref, OutputFile => $fh); +Note, XML::Simple does not require that the object you pass in to the +OutputFile option inherits from L<IO::Handle> - it simply assumes the object +supports a C<print> method. + =head2 ParserOpts => [ XML::Parser Options ] I<# in - don't use this> I<Note: This option is now officially deprecated. If you find it useful, email |