#!/usr/bin/perl


for ($DATE=1; $DATE<=31; $DATE++) {
	unless (-d $DATE) { mkdir $DATE; }
	print "DATE: $DATE\n";

	for ($a2=0; $a2<=255; $a2++) {
		for ($a3=0; $a3<=255; $a3++) {
			$idnum = "$a2.$a3";
			$idcrypt = substr(crypt($idnum * $idnum, sprintf("%02s",$DATE)), -8); 
			&write_list($idcrypt, $idnum, $DATE);
		}
	}
	
	for ($a3=0; $a3<=255; $a3++) {
		$idnum = ".$a3";
		$idcrypt = substr(crypt($idnum * $idnum, sprintf("%02s",$DATE)), -8); 
		&write_list($idcrypt, $idnum, $DATE);

		$idnum = "$a3";
		$idcrypt = substr(crypt($idnum * $idnum, sprintf("%02s",$DATE)), -8); 
		&write_list($idcrypt, $idnum, $DATE);

		for ($a2=0; $a2<=9; $a2++) {
			$idnum = sprintf("%02s.$a3",$a2);
			$idcrypt = substr(crypt($idnum * $idnum, sprintf("%02s",$DATE)), -8); 
			&write_list($idcrypt, $idnum, $DATE);
		}
	}
	
	for ($a3=0; $a3<=9; $a3++) {
		$idnum = sprintf("%02s",$a3);
		$idcrypt = substr(crypt($idnum * $idnum, sprintf("%02s",$DATE)), -8); 
		&write_list($idcrypt, $idnum, $DATE);
	}

}

# unless (-d '000826') { mkdir '000826'; }
# for ($hour=0; $hour<=2; $hour++) {
# 	unless (-d '000826/$hour') { mkdir "000826/$hour"; }
# 	print "hour: $hour"."X\n";
# 
# 	for ($a2=0; $a2<=255; $a2++) {
# 		for ($a3=0; $a3<=255; $a3++) {
# 			$idnum = "$a2.$a3";
# 			$idcrypt = substr(crypt($idnum * $idnum, " $hour"), -8); 
# 			&write_list($idcrypt, $idnum, "000826/$hour");
# 		}
# 	}
# 	
# 	for ($a3=0; $a3<=255; $a3++) {
# 		$idnum = ".$a3";
# 		$idcrypt = substr(crypt($idnum * $idnum, " $hour"), -8); 
# 		&write_list($idcrypt, $idnum, "000826/$hour");
# 
# 		$idnum = "$a3";
# 		$idcrypt = substr(crypt($idnum * $idnum, " $hour"), -8); 
# 		&write_list($idcrypt, $idnum, "000826/$hour");
# 
# 		for ($a2=0; $a2<=9; $a2++) {
# 			$idnum = sprintf("%02s.$a3",$a2);
# 			$idcrypt = substr(crypt($idnum * $idnum, " $hour"), -8); 
# 			&write_list($idcrypt, $idnum, "000826/$hour");
# 		}
# 	}
# 	
# 	for ($a3=0; $a3<=9; $a3++) {
# 		$idnum = sprintf("%02s",$a3);
# 		$idcrypt = substr(crypt($idnum * $idnum, " $hour"), -8); 
# 		&write_list($idcrypt, $idnum, "000826/$hour");
# 	}
# 
# }
# 
# exit;

sub write_list() {
	my ($id, $idnum, $path) = @_;
	$id =~ /(^.)/;
	my $idt = $1;
	$idt =~ tr/A-Z\/\./a-z_,/;
	my $fn = "$idt.lst";
	open(LIST, ">>$path/$fn");
	print LIST "$id $idnum\n";
	close(LIST);
}
