kp said:
Hi all,
I want to copy a text to clipboard in UNIX.
Is there a way to do this in Perl?
Or should I use some other language?
Thanks,
Krishna
Although Tk originated with TCL, it's available for Perl, and it can
manipulate the selection for you:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
# Let's be funny and name the window $winxp.
my $winxp = MainWindow->new();
$winxp->Label (-text => 'Hello World')->pack();
$winxp->Button (-text => 'Quit' ,
-command => [ $winxp => 'destroy' ]
)->pack; $winxp->SelectionClear ();
$winxp->SelectionHandle (\&myhandler);
$winxp->SelectionOwn ();
MainLoop;
sub myhandler {
my ($offset, $maxChars) = @_;
return "This is text from Perl.";
}
# Credits to the authors of the perl-tk manpage.
Read the docs;
$ man perl-tk
$ man Tk::Selection