Return to Snippet

Revision: 15335
at July 4, 2009 03:42 by mitry


Updated Code
@rem = '--*-Perl-*--
@perl -x -S %0 %* && exit /b && '
#!/usr/bin/perl -w
#line 3

=head1 NAME

clip.cmd - put/get Windows system clipboard.

=head1 USAGE

   clip < text.txt
   type text.txt | clip
   
put text to windows clipboard

   clip > file.bmp

save bitmap from clipboard to file   
   
=head1 DEPENDENCIES

Perl module Win32::Clipboard required.

The script must be wrapped as windows cmd to proper handle input/output
redirection.

=head1 AUTHOR

dMitry <[email protected]>

=cut

use Win32::Clipboard;
my $clip=Win32::Clipboard();

if (-t STDIN ) {	# Nothing on input, so print clipboard
	binmode STDOUT	if $clip->IsBitmap();
	local $,="\n"	if $clip->IsFiles();
	print $clip->Get();
} else {		# STDIN redirected, so put it in clipboard
	local $/;
	$clip->Set(<STDIN>);
}

__END__
:endofperl

Revision: 15334
at July 1, 2009 08:09 by mitry


Initial Code
@rem = '--*-Perl-*--
@perl -x -S %0 %* && exit /b && rem ';
#!/usr/bin/perl -w
#line 3

=head1 NAME

clip.cmd - put/get Windows system clipboard.

=head1 USAGE

   clip < text.txt
   type text.txt | clip
   
put text to windows clipboard

   clip > file.bmp

save bitmap from clipboard to file   
   
=head1 DEPENDENCIES

Perl module Win32::Clipboard required.

The script must be wrapped as windows cmd to proper handle input/output
redirection.

=head1 AUTHOR

dMitry <[email protected]>

=cut

use Win32::Clipboard;
my $clip=Win32::Clipboard();

if (-t STDIN ) {	# Nothing on input, so print clipboard
	binmode STDOUT	if $clip->IsBitmap();
	local $,="\n"	if $clip->IsFiles();
	print $clip->Get();
} else {		# STDIN redirected, so put it in clipboard
	local $/;
	$clip->Set(<STDIN>);
}

__END__
:endofperl

Initial URL


Initial Description


Initial Title
clip.cmd - get/put Windows system clipboard

Initial Tags


Initial Language
Perl