Skip Menu |

This queue is for tickets about the YAML-Tiny CPAN distribution.

Report information
The Basics
Id: 77875
Status: resolved
Priority: 0/
Queue: YAML-Tiny

People
Owner: Nobody in particular
Requestors: daniel.carosone [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Would like to be able to pass IO::File handles to Dump/LoadFile
Date: Mon, 18 Jun 2012 16:31:39 +1000
To: bugs-yaml-tiny [...] rt.cpan.org
From: Daniel Carosone <daniel.carosone [...] gmail.com>
It would be nice to be able to pass an io handle to LoadFile/Dumpfile, rather than just a string filename. Obvious use case would be layered gzip compression, though Archive::Zip::MemberRead and many others might also be useful. The alternative is passing a content string fetched already to read_string. There's no saving of efficiency since that's what read does internally anyway, but it would make for much neater calling code to just be able to pass the handle. The write() function looks like it might just work passing a ":layer filename" string, because it concat's "<" onto the start for a 2-argument open. The read() function does a bunch of -f tests on the passed string which defeat attempts to pass a 2-argument open string. I haven't actually tried this trick with write, mostly because I want it more for LoadFile and IO:Uncompress:AnyUncompress with transparent (to not care whether i have manually gzip'd the files), and it won't work there. A very-low priority wishlist item, but: I notice some other comments about utf8 encoding, and wonder whether the solution to those doesn't also involve allowing it to use perlio layers. -- Dan.
On Mon Jun 18 02:31:49 2012, daniel.carosone@gmail.com wrote: Show quoted text
> It would be nice to be able to pass an io handle to LoadFile/Dumpfile, > rather than just a string filename. Obvious use case would be layered gzip > compression, though Archive::Zip::MemberRead and many others might also be > useful.
I think the wisdom of this depends a lot on whether Dump/Load continue to deal with characters (as YAML.pm does) or change to deal with UTF-8 encoded octets (as YAML::XS does). See https://rt.cpan.org/Ticket/Display.html?id=76180 for more on that. If this does get implemented, I wonder if it's possible to check the layers for correct encoding support (or raw mode). Or the function should binmode the handle itself for what is needed.
On reflection, this isn't something that YAML::Tiny will implement independently of the rest of the YAML ecosystem. And YAML::Tiny doesn't stream, so there's no advantage over just calling read_string or write_string and using the results with your own handle. Closing this ticket.