#!//usr/bin/perl
unlink ("plget.txt");
print "Please enter an URL(Hisshu_desu!): ";
$url = <STDIN>;
chomp($url);
print "Please enter a Saisho_chi(Hisshu_desu!): ";
$head = <STDIN>;
print "Please enter a Saidai_chi(Hisshu_desu!): ";
$tail = <STDIN>;
print "Please enter a Zeroume_no_Keta(=>0?): ";
$zeroume = <STDIN>;
chomp($zeroume);
print "Please enter a Kakuchoshi(=>jpg?): ";
$kakuchoshi = <STDIN>;
chomp($kakuchoshi);
print "Please enter a Suji_Ikou_no_Mojiretsu(=>Null?): ";
$aftint = <STDIN>;
chomp($aftint);
foreach $count ($head .. $tail) {	#頭の数字、お尻の数字
select (OUT);
  open (OUT, ">>plget.txt");		#テキスト出力
	print $url;#URL
	if ($zeroume == 0) {		#桁数
		printf "%0d", $count;
	} elsif ($zeroume == 1) {
		printf "%01d", $count;
	} elsif ($zeroume == 2) {
		printf "%02d", $count;
	} elsif ($zeroume == "3") {
		printf "%03d", $count;
	} elsif ($zeroume == 4) {
		printf "%04d", $count;		
	} elsif ($zeroume == 5) {
		printf "%05d", $count;
	} elsif ($zeroume == 6) {
		printf "%06d", $count;
	} elsif ($zeroume == 7) {
		printf "%07d", $count;
	} elsif ($zeroume == 8) {
		printf "%08d", $count;				
	} elsif ($zeroume == 9) {
		printf "%09d", $count;
	} elsif ($zeroume == 10) {
		printf "%010d", $count;			
	} else {
		printf "%0d", $count;
	}
	print "$aftint";			#数字以降の文字列
 if($kakuchoshi){
    print ".","$kakuchoshi\n";		#拡張子
 } else {
  print ".jpg\n";
  close OUT;					#テキストクローズ
 }
}
$code = "wget -c -t 1 -i plget.txt";
system $code;				#コマンド実行
