Mediawiki perl

==This is the 1 scripts==
 
 use LWP::UserAgent; 
 $ua = LWP::UserAgent->new; 
 
 my $req = HTTP::Request->new(GET => 
 'http://xntz.swu.edu.cn/OAWeb/jsp/commonFjViewAction.do?funcname=OatyfjbBP.viewFj&inttyfjlsh=20111003233&intfjlxbh=1'); 
 
 $res = $ua->request($req, "C:\Users\echo\cutof.doc"); 
 if ($res->is_success) { 
 print "ok\n"; 
 } 
 else { 
 print $res->status_line, "\n"; 
 } 
 
 
==This is the 2 scripts==
#!/usr/bin/perl -w 
# diary-link-checker - check links from diary page 
 
use strict; 
use LWP; 
use LWP::Simple; 
 
my $doc_url = "http://pleac.sourceforge.net/pleac_perl/"; 
my $document; 
my $browser; 
init_browser( ); 
 
{ # Get the page whose links we want to check: 
 my $response = $browser->get($doc_url); 
 die "Couldn't get $doc_url: ", $response->status_line 
 unless $response->is_success; 
 $document = $response->content; 
 $doc_url = $response->base; 
 # In case we need to resolve relative URLs later 
} 
 
while ($document =~ m/HREF\s*=\s*"([^"\s]+.html)"/gi) { 
 
 my $absolute_url = absolutize($1, $doc_url); 
 check_url($absolute_url); 
 getstore($absolute_url,$1); 
} 
 
sub absolutize { 
 my($url, $base) = @_; 
 use URI; 
 return URI->new_abs($url, $base)->canonical; 
} 
 
sub init_browser { 
 $browser = LWP::UserAgent->new; 
 # ...And any other initialization we might need to do... 
 return $browser; 
} 
 
sub check_url { 
 # A temporary placeholder... 
 print "I should check $_[0]\n"; 
 
} 
 
==This is the 3 scripts==
use HTML::TokeParser; 
 
my $stream = HTML::TokeParser->new("test.html") 
 || die "Couldn't read HTML file $filename: $!"; 
# For a string: HTML::TokeParser->new( \$string_of_html 
while (my $token = $stream->get_token) { 
 if ($token->[0] eq 'T') { # text 
 # process the text in $token->[1] 
 print $token->[1]; 
 } elsif ($token->[0] eq 'S') { # start-tag 
 my($tagname, $attr) = @$token[1,2]; 
 # consider this start-tag... 
 
 } elsif ($token->[0] eq 'E') { 
 my $tagname = $token->[1]; 
 # consider this end-tag 
 } 
 
 # ignoring comments, declarations, and PIs 
} 
==This is the 4 scripts==
 use LWP::UserAgent; 
 $ua = LWP::UserAgent->new; 
 
 my $req = HTTP::Request->new(GET => 
 'http://xntz.swu.edu.cn/OAWeb/jsp/commonFjViewAction.do?funcname=OatyfjbBP.viewFj&inttyfjlsh=20111003233&intfjlxbh=1'); 
 
 $res = $ua->request($req, "C:\Users\echo\cutof.doc"); 
 if ($res->is_success) { 
 print "ok\n"; 
 } 
 else { 
 print $res->status_line, "\n"; 
 } 
 
 
==This is the 5 scripts==
use Mail::SendEasy; 
 
 
 
 my $mail = new Mail::SendEasy( 
 smtp => 'smtp.163.com' , 
 user => 'echowuhao' , 
 pass => 222007327, 
 ) ; 
 
 my $status = $mail->send( 
 from => 'echowuhao@163.com' , 
 from_title => 'Foo Name' , 
 # reply => 're@foo.com' , 
 # error => 'error@foo.com' , 
 to => 'echowuhao@gmail.com' , 
 # cc => 'recpcopy@domain.foo' , 
 subject => "MAIL Test" , 
 # msg => "The Plain Msg..." , 
 html => "The HTML Msg..." , 
 # msgid => "0101" , 
 ) ; 
 
 if (!$status) { print $mail->error ;} 
==This is the 6 scripts==
 
use strict; 
use HTML::TreeBuilder; 
use HTML::FormatText; 
use LWP::Simple; 
my $webpage = get("http://www.swu.edu.cn/index.jsp"); 
print $webpage; 
my $htmltree = HTML::TreeBuilder->new->parse($webpage); 
my $output = HTML::FormatText->new(); 
print $output->format($htmltree); 
==This is the 7 scripts==
#!/usr/bin/perl 
 use strict; 
 use warnings; 
 use Email::Send; 
 use Email::Send::Gmail; 
 use Email::Simple::Creator; 
 
 my $email = Email::Simple->create( 
 header => [ 
 From => 'echowuhao@gmail.com', 
 To => 'echowuhao@gmail.com', 
 Subject => 'test', 
 ], 
 body => 'I am testing if it is ok.', 
 ); 
 
 my $sender = Email::Send->new( 
 { mailer => 'Gmail', 
 mailer_args => [ 
 username => 'echowuhao@gmail.com', 
 password => '222007327', 
 ] 
 } 
 ); 
 eval { $sender->send($email) }; 
 die "Error sending email: $@" if $@; 
==This is the 8 scripts==
 use Email::Send; 
 
 my $mailer = Email::Send->new( { 
 mailer => 'SMTP::TLS', 
 mailer_args => [ 
 Host => 'smtp.gmail.com', 
 Port => 587, 
 User => 'echowuhao@gmail.com', 
 Password => '222007327', 
 Hello => 'abcde', 
 ] 
 } ); 
 
 use Email::Simple::Creator; # or other Email:: 
 my $email = Email::Simple->create( 
 header => [ 
 From => 'echowuhao@gmail.com', 
 To => 'echowuhao@gmail.com', 
 Subject => 'Subject title', 
 ], 
 body => 'echowuhao@gmail.com', 
 ); 
 
 eval { $mailer->send($email) }; 
 die "Error sending email: $@" if $@; 
==This is the 9 scripts==
 use strict; 
 use warnings; 
 
 use Email::Send::SMTP::Gmail; 
 
 my $mail=Email::Send::SMTP::Gmail->new( -smtp=>'gmail.com', 
 -login=>'echowuhao@gmail.com', 
 -pass=>'222007327'); 
 
 $mail->send(-to=>'echowuhao@gmail.com', 
 -subject=>'Hello!', 
 -verbose=>'1', 
 -body=>'Just testing it'); 
 
 $mail->bye; 
==This is the 10 scripts==
 use strict; 
 use warnings; 
 use Email::Send; 
 use Email::Send::Gmail; 
 use Email::Simple::Creator; 
 
 my $email = Email::Simple->create( 
 header => [ 
 From => 'echowuhao@gmail.com', 
 To => 'echowuhao@gmail.com', 
 Subject => 'Server down', 
 ], 
 body => 'The server is down. Start panicing.', 
 ); 
 
 my $sender = Email::Send->new( 
 { mailer => 'Gmail', 
 mailer_args => [ 
 username => 'echowuhao@gmail.com', 
 password => '222007327', 
 ] 
 } 
 ); 
 eval { $sender->send($email) }; 
 die "Error sending email: $@" if $@; 
==This is the 11 scripts==
 use HTML::FormatRTF; 
 my $infile = "C:/Users/echo/Documents/perl/patternmatching.html"; 
 my $outfile = "formated.rtf."; 
 open OUT, ">$outfile" 
 or die "Can't write-open $outfile: $!\n"; 
 # my $string = HTML::FormatText->format_file( 
 # $infile, 
 # leftmargin => 0, rightmargin => 50 
 # ); 
 print OUT HTML::FormatRTF->format_file( 
 $infile, 
 'fontname_headings' => "Verdana", 
 # leftmargin => 0, 
 # rightmargin => 50 
 ); 
 close(OUT); 
==This is the 12 scripts==
 use HTML::WikiConverter; 
 my $infile = "http://eli.thegreenplace.net/2008/11/01/academic-publications/"; 
 my $wc = new HTML::WikiConverter( dialect => 'MediaWiki' ); 
 my $outfile = "formated.txt"; 
 # open IN,"<",$infile; 
 open OUT, ">$outfile" 
 or die "Can't write-open $outfile: $!\n"; 
 # print OUT $wc->html2wiki(file=>$infile); 
 print OUT $wc->html2wiki(uri=>$infile,encoding=>"utf-8"); 
 close(OUT); 
==This is the 13 scripts==
use Sys::Hostname; 
use Socket; 
my $host = hostname(); 
my $address = inet_ntoa( scalar gethostbyname( $host || 'localhost' ) ); 
print $address 
 
#怎样得到本机ipv6 地址？ 
==This is the 14 scripts==
instmodsh 
==This is the 15 scripts==
 #!/usr/bin/perl 
 
 use strict; 
 use WWW::Mechanize; 
 my $agent = WWW::Mechanize->new(); 
 $agent->get('http://202.202.96.53/index.jsp'); 
 $agent->form_number('1'); 
 $agent->field('username',"wuhao"); 
 $agent->field('password',"466311"); 
 $agent->submit(); 
 
==This is the 16 scripts==
use LWP::Simple; 
#$doc = get 'http://www.swu.edu.cn'; 
#print $doc 
#my $code = getstore('http://www.yahoo.cn', 'C:\Users\echo\file.html'); 
#!/usr/bin/perl -w 
use strict; 
use LWP::Simple; 
my $url = 'http://www.somesite.com/somefile'; 
head($url) ? print "Good\n" : print "No file\n" 
 
__END__ 
 
use strict; 
use warnings; 
use LWP::Simple; 
my $url = 'http://www.booktv.org/schedule/'; 
my $file = 'booktv.html'; 
my $status = getstore($url, $file); 
die "Error $status on $url" unless is_success($status); 
open(IN, "<$file") || die "Can't open $file: $!"; 
while (<IN>) { 
 if (m/Gore\s+Vidal/) { 
 print "Look! Gore Vidal! $url\n"; 
 last; 
 } 
} 
close(IN); 
 
use strict; 
use LWP::Simple; 
foreach my $url ( 
 'http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif', 
 'http://hooboy.no-such-host.int/', 
 'http://www.yahoo.com', 
 'http://www.ora.com/ask_tim/graphics/asktim_header_main.gif', 
 'http://www.guardian.co.uk/', 
 'http://www.pixunlimited.co.uk/siteheaders/Guardian.gif', 
) { 
 print "\n$url\n"; 
 
 my ($type, $length, $mod) = head($url); 
 # so we don't even save the expires or server values! 
 
 unless (defined $type) { 
 print "Couldn't get $url\n"; 
 next; 
 } 
 print "That $type document is ", $length || "???", " bytes long.\n"; 
 if ($mod) { 
 my $ago = time( ) - $mod; 
 print "It was modified $ago seconds ago; that's about ", 
 int(.5 + $ago / (24 * 60 * 60)), " days ago, at ", 
 scalar(localtime($mod)), "!\n"; 
 } else { 
 print "I don't know when it was last modified.\n"; 
 } 
} 
==This is the 17 scripts==
<source lang="perl" line >
# find all the perl file(end with .pl) 
# edit the file; make it start with 
# merge the file one by one 
# 
@files=glob(' *.pl'); 
# @ARGV = qw# larry moe curly #; 
@ARGV=@files; 
my $i=1;
open(OUT,'>',"allfiles.pl") or die $!; 
while (<>) { 
chomp; 
# print $i; 
select OUT; 
print "$_ \n"; 
if (eof) { 
 print '</source>'; 
 $i++; 
 printf "\n==This is the %d scripts==\n",$i; 
 print '<source lang="perl" line >'; 
 print "\n"; 
} 
 
} 
# print 
# while (<$_>) { 
# chomp; 
# # $i++; 
# # print $i; 
# print OUT "$_ \n"; 
# 
# } 
</source>
==This is the 18 scripts==
use strict; 
use warnings; 
print "hello perl 5"; 
==This is the 19 scripts==
use strict; 
# @ARGV = qw#source.txt #; 
# local $/ = "species\n"; 
# while (<>) { 
# chomp; 
# local $/ = "species"; 
# 
# print "Record $. is\n$_\n"; 
# } 
# my @species; 
# my %species; 
open INPUT,"<","source.txt"; 
while (<INPUT>) { 
chomp; 
# push @species,"$_" unless $_ eq "species"; 
# } 
# 
# print "@species\n"; 
# %species = @species; 
# print %species; 
# print $species{arcifera}; 
 
open OUTPUT,">>", "target.txt"; 
select OUTPUT; 
 
if ($_ eq "species" ) { 
	print "\n*species "; 
} elsif($_ eq "synonym") { 
	print "\n*synonym "; 
} elsif($_ eq "genus"){ 
	print "\n ==genus"; 
}else{ 
	print " $_";} 
close OUTPUT; 
} 
==This is the 20 scripts==
# use strict; 
 $_ = "http://www.swu.edu.cn/images/index_r2_c6.jpg"; 
if( $_ =~ /http:\/\/([^\/]*)(.*)/){ 
 print $1; 
 print "nothing"; 
 print $2; 
 
 
} 
#($first,$second) = ($_ =~ /http:\/\/(.*)\/(.*)/); 
 
#print $first; 
#print $second ; 
print "nothing \n"; 
#print "test"; 
 
 # why is there always mistakes? 
==This is the 21 scripts==
use strict; 
use LWP::Simple; 
foreach my $url ( 
 'http://us.a1.yimg.com/us.yimg.com/i/ww/m5v9.gif', 
 'http://hooboy.no-such-host.int/', 
 'http://www.yahoo.com', 
 'http://www.ora.com/ask_tim/graphics/asktim_header_main.gif', 
 'http://www.guardian.co.uk/', 
 'http://www.pixunlimited.co.uk/siteheaders/Guardian.gif', 
) { 
 print "\n$url\n"; 
 my $status = getstore($url, $file); 
 die "Error $status on $url" unless is_success($status); 
 open(IN, "<$file") || die "Can't open $file: $!"; 
 while (<IN>) { 
 if (m/Gore\s+Vidal/) { 
 print "Look! Gore Vidal! $url\n"; 
 last; 
 } 
} 
close(IN); 
} 
==This is the 22 scripts==
use strict; 
my @arr=[1,2,3,3,3,3,4,5,7,8,8,9]; 
my @sorted=insert_sort(@arr); 
print "@arr"; 
print @sorted; 
print "this is the end"; 
sub insert_sort{ 
	my(@a)=@_; 
	my $j,my $i,my $key; 
	for($j=1; $j<=@a;$j++){ 
		$key=$a[$j]; 
		$i=$j-1; 
		while($i=>0 and $a[$i]>$key){ 
			$a[$i+1]=$a[$i]; 
			$i=$i-1} 
			} 
			 
	$a[$i+1]=$key 
	 
	} 
==This is the 23 scripts==
#!/usr/bin/perl -w 
# pl8.pl - query California license plate database 
 
use strict; 
use LWP::UserAgent; 
 
my $browser = LWP::UserAgent->new; 
my $response = $browser->post( 
 'http://202.202.96.57/login/login1.jsp', 
 [ 
 'username' => "wuhao5", 
 'password' => "466311", 
 'if_login' => "N", 
 'B2' => "submit" 
 ], 
); 
 die "Error: ", $response->status_line 
 unless $response->is_success; 
 
exit; 
==This is the 24 scripts==
print '<source lang="perl" line >'; 
print "\n"; 
print ''; 
</source>
==This is the 25 scripts==
use Win32::Process; 
use Win32; 
use Web::Scraper; 
print "ht"; 
==This is the 26 scripts==
#!/usr/bin/perl 
 # 
 
 use threads; 
 use Thread::Queue; 
 
 my $q = Thread::Queue->new(); 
 
 sub produce { 
 my $name = shift; 
 while(1) { 
 my $r = int(rand(100)); 
 $q->enqueue($r); 
 printf("$name produce $r\n"); 
 sleep(int(rand(3))); 
 } 
 } 
 
 sub consume { 
 my $name = shift; 
 while(my $r = $q->dequeue()) { 
 printf("consume $r\n"); 
 } 
 } 
 
 my $producer1 = threads->create(\&produce, "producer1"); 
 my $producer2 = threads->create(\&produce, "producer2"); 
 my $consumer1 = threads->create(\&consume, "consumer2"); 
 
 $producer1->join(); 
 $producer2->join(); 
 $consumer1->join(); 
==This is the 27 scripts==
 # Create a user agent object 
 use LWP::UserAgent; 
 my $ua = LWP::UserAgent->new; 
 $ua->agent("MyApp/0.1 "); 
 # Create a request 
 my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search'); 
 $req->content_type('application/x-www-form-urlencoded'); 
 $req->content('query=libwww-perl&mode=dist'); 
 # Pass request to the user agent and get a response back 
 my $res = $ua->request($req); 
 # Check the outcome of the response 
 if ($res->is_success) { 
 print $res->content; 
 } 
 else { 
 print $res->status_line, "\n"; 
 } 
==This is the 28 scripts==
use WWW::Mechanize; 
 
my $mech = WWW::Mechanize->new( autocheck => 1 ); 
$mech->get( "http://202.202.96.53/index.jsp" ); 
 print $mech->content; 
 
$browser->form_number(1); 
 $browser->field("query", $module_name); 
 $browser->click();