質問があります。お役に立てれば幸いです。
次の内容を含む 2 つのテキスト ファイルがあります。
FILE1.txt
http://www.dog.com/
http://www.cat.com/
http://www.antelope.com/
FILE2.txt
1
2
Barry
私が正しく達成した出力は次のとおりです。
http://www.dog.com/1
http://www.dog.com/2
http://www.dog.com/Barry
http://www.cat.com/1
http://www.cat.com/2
http://www.cat.com/Barry
http://www.antelope.com/1
http://www.antelope.com/2
http://www.antelope.com/Barry
上記を行うコード
open my $animalUrls, '<', 'FILE1.txt' or die "Can't open: $!";
open my $directory, '<', 'FILE2.txt' or die "Can't open: $!";
my @directory = <$directory>; #each line of the file into an array
close $directory or die "Can't close: $!";
while (my $line = <$animalUrls>) {
chomp $line;
print $line.$_ foreach (@directory);
push (@newListOfUrls, $line.$_) foreach (@directory); #put each new url into array
}
今私が抱えている問題:
元の URL (File1.txt) の Content Length を取得し、新しい URL のそれぞれの Content-Length を対応する元の URL と比較して、それらが同じか異なるかを確認する必要があります。次に例を示します。
- http://www.dog.com/1の Content-Length と元の URL http://www.dog.com/の Content-Length を比較して、違いがあるかどうかを確認する必要があります。
- 次に、http://www.dog.com/2 の Content-Length と元の URL http://www.dog.com/ の Content-Length を比較して、違いがあるかどうかを確認する必要があります。
- 次に、http://www.dog.com/Barry の Content-Length と元の URL http://www.dog.com/ の Content-Length を比較して、違いがあるかどうかを確認する必要があります。
- 次に、http://www.cat.com/1 の Content-Length と元の URL http://www.cat.com/ の Content-Length を比較して、違いがあるかどうかを確認する必要があります。
- 次に、http://www.cat.com/2 の Content-Length と元の URL http://www.cat.com/ の Content-Length を比較して、違いがあるかどうかを確認する必要があります。
- 等々........
Content-Length を取得するコード:
print $mech->response->header('Content-Length'); #returns the content length
私が問題を抱えているのは、新しい各 URL を対応する正しい元の URL と比較する方法です。(つまり、 http://www.cat.com/Barry の Content-Length とhttp://www.dog.com/の Content-Length を誤って比較しないでください)それ?
これに関するあなたの助けは大歓迎です、どうもありがとう