The above is a trivial example, below I've included a script which incorporates this technique for polling http://thesaurus.reference.com for a word entry in Roget's Thesaurus, filtering (brutally I'll admit) out all the ads and pop ups associated.#!/usr/bin/perl -w use strict; my($data,$word); my(@letters); open (FROM_CLIPBOARD, "pbpaste|"); open (TO_CLIPBOARD, "|pbcopy"); $data=<FROM_CLIPBOARD>; if ($data){ $word=$data ;} else { $word = "forwards"; } @letters=split(//,$word); print TO_CLIPBOARD reverse(@letters),"\n"; close (FROM_CLIPBOARD); close (TO_CLIPBOARD);
#!/usr/bin/perl -w #=========== declare includes ============= use strict; use diagnostics-verbose; #========== declare variables ============= my($URL,$content,$test,$word); my(@content,@filtered); #============= script body ================ open (FROM_CLIPBOARD, "pbpaste|"); open (TO_CLIPBOARD, "|pbcopy"); $test=<FROM_CLIPBOARD>; $test ? $word=$test : print "what word are you looking for?\t"; $wo +rd=<>; chomp($word); $URL= "http://thesaurus.reference.com/search?q=$word&db=roget"; print "getting the data for the word \"",$word,"\"....\n"; use LWP::Simple; unless (defined ($content = get $URL)) { die "could not get $URL\n"; } print "filtering the data ....\n"; (undef,$content)=split (/<!-- Content -->/,$content); ($content,undef)=split (/<!-- End content -->/,$content); @content= split (/<tr>/,$content); for (@content){ next unless /<[^>]td*>/; next unless /:|,/; next if /Source:|Entry/; last if /Try your search for/; s/ //gs; s/<[^>]*>//gs; push (@filtered,$_,"\n"); } print "directing output to clipboard...\n"; print TO_CLIPBOARD @filtered; print "done.\n"; close(FROM_CLIPBOARD); close(TO_CLIPBOARD);
In reply to OSX perl2clipboard by Sol-Invictus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |