perl代码解析,救命啊,马上结账
小弟没用过perl,现在上头让我解析这代码,哪位大哥能帮我一行行讲讲啊!!
这代码作了什么?谢谢阿!!
sub cacheclear {
my ($targethost, $diffdata, $servicename, $CDir, $PDir) = @_;
foreach my $i (sort keys %{$diffdata}) {
# foreach my $j (keys %{$diffdata{$i}}) {
foreach my $j (keys %{$diffdata{$i}}) {
if ($diffdata{$i}{$j} !~ /^\s*$/) {
my @url = ();
if ($j eq "NEWSITEMID ") {
push (@url, "$CDir?n=$diffdata{$i}{$j} ");
push (@url, "$CDir?ichiran=True&n=$diffdata{$i}{$j} ");
} else {
push (@url, "$diffdata{$i}{$j} ");
}
print DEBUG "$i : $j : $diffdata{$i}{$j}\n ";
foreach my $u (@url) {
my $sock = IO::Socket::INET-> new(PeerAddr => "$targethost ",
PeerPort => 80,
Proto => 'tcp ',
Timeout => 10);
if (! $sock){
return;
}
print "Connected $targethost:80\n " if $debug;
print "GET ||$u|| HTTP/1.0\r\n " if $debug;
print DEBUG "$$ : $targethost : GET ||$u|| HTTP/1.0\r\n " if $debug;
print $sock "GET $u HTTP/1.0\r\n ";
print $sock "Host: $servicename\r\n ";
print $sock "Cache-Control: no-cache\r\n\r\n ";
while( <$sock> ){
####
}
close ($sock)
}
}
}
}
}
------解决方案--------------------帮你顶一下,只能这样了,我也不会。