http://qs321.pair.com?node_id=197559

joe++ has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'm in the process of connecting the ouput of one external module to the input of another external module. The problem ist that the caller gives me a scalar ref, while I can call the imported method only with a file handle for output.

My solution is to pass the incoming scalar reference to one of IO::File or IO::Scalar, and then passing the resulting file handle along to the next function.

Now my question is: which IO::* module should I pick, considering that I want to ditribute my code to the general Perl users audience?

The docs of IO::Scalar mention IO::String as being its potential successor, but there is only one release of this module on CPAN, which also predates IO::Scalar's latest release...

Example code (snippet):

... # do they provide a scalar ref as output buffer? if ($output_ref) { $fh_out = new IO::Scalar($output_ref); } ... if (defined $fh_out) { # write XML to the scalar-tied file handle $self->{x_out} = new XML::Writer(OUTPUT => $fh_out); } else { # default: print to STDOUT $self->{x_out} = new XML::Writer(); } ...
Any help and opinions are welcome!

Joe.