改良的sdcv.pl


 1 #!/usr/bin/perl

 2 use Getopt::Long;

 3

 4 # 参数:单行输出选择。屏幕提示输出选择。

 5 GetOptions(1 => \$oneline, n=>\$notify);

 6

 7 my $out,$in;

 8 # 无参数时,使用剪贴板内容。

 9 $in=$ARGV[0]; if(!$in){$in=`xsel -o`;} if(!$in){exit;}

10 open(SDCV,"sdcv -n $in|");

11 my $r;

12 while($l=<SDCV>){

13 if($l!~/^$/){$r=$l;chomp($r);$r=~s/–>//;}

14 else{$out="$r –> ";last;}

15 }

16 while($l=<SDCV>){

17 if($l=~/相关|^$/){

18 close(SDCV);

19 if($notify){`notify-send -i ‘/home/exp/媒体/128软件png/pidgin.png’ ’sdcv翻译’ "$out"`;}

20 else{print $out;}

21 exit;

22 }

23 chomp($l) if($oneline);

24 $out.=" ► $l";

25 }

26

27

One Response to “改良的sdcv.pl”

  1. pazzo Says:

    同学 你这个黄色太艳了 在google reader 里看特晃眼。。。。

Leave a Reply



Spam Protection by WP-SpamFree