# Yup, this is a bonus program, not in the book! # # This program reads the RTF component of the MSWin system clipboard, # and sends it to STDOUT. # # If there is no such clipboard component, we die with an error message. use strict; use Win32::Clipboard; my %name2num; my @formatnums = Win32::Clipboard::->EnumFormats(); @name2num{ map( Win32::Clipboard::->GetFormatName($_) || $_, @formatnums)} = @formatnums ; die "No RTF on the clipboard at the moment.\n" unless exists $name2num{'Rich Text Format'}; binmode(STDOUT); # avoid turning \cm\cj's into \cm\cm\cj's print STDOUT '', Win32::Clipboard::->GetAs( $name2num{'Rich Text Format'} ); exit; __END__