[RFC] IO::Clipboard

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


It occurred to me that given Ryan King's Clipboard module, an
IO::Clipboard module wouldn't be too hard.

First cut: it's a subclass of IO::String. For input, just load the
string from the clipboard. For ouput, stash a string reference in one of
the unused slots of the glob IO::String returns; the DESTROY method
flushes the output to the clipboard.

Second cut: we only use IO::String for $] < 5.008. For 5.8, we generate
the glob reference directly. For input, we grab the contents of the
clipboard and use the 3-argument "open" syntax to open a reference to
the retrieved text. For output, we generate a reference to an empty
string, open that, and the rest of the logic is as for the IO::String

Third cut: For history's sake, if it's MSWin32 we fall back to
Win32::Clipboard if Clipboard isn't available. Or maybe we implement
directly to Win32::Clipboard (since it looks like Clipboard just wraps
Win32::Clipboard under MSWin32 anyway). I seem to remember having to
massage "\n"-delimited text into "\r\n" before putting it on the MSWin32
clipboard, but have no way to check it right now. Ryan King's module
doesn't do this, but I don't know whether that means my memory is wrong,
or whether nobody's using this module under MSWin32.


Tom Wyant

Site Timeline