use strict;
use Encode;
use Win32::Clipboard;
use IO::Handle;
use Time::HiRes 'sleep';
system("");
STDOUT->autoflush(1);
#输入某些敏感符号的参数时请使用双引号引用
if ($#ARGV < 1)
{
print encode('gbk', decode('utf8', "缺少参数"));
exit;
}
#建议在中文输入法的环境下使用命令行
my $all;
my $clip = Win32::Clipboard->new();
system("");
$all = $clip->GetText();
while ($all eq "")
{
$all = $clip->GetText();
print ".";
sleep 0.5;
}
print "Before: \n$all\n";
$all=~s/$ARGV[0]/$ARGV[1]/g;
$clip->Set($all);
print "After: \n$all\n";
示例:
[tcode="Console>replace.pl \t " ""]Before:
555555 e
6666666 f
77777777 g
After:
555555 e
6666666 f
77777777 g[/tcode]