´äº¯ °¨»çÇÕ´Ï´Ù. ±×·¡¼. Á¦°¡ ¼ºêÇÔ¼ö¸¦ ¸¸µé¾ú°Åµç¿ä.
Á¦°¡ ¼ºê·çƾÇÔ¼ö¸¦ ¸¸µé¾î¼.. foreach¹®¾È¿¡¼ µ¹¸±·Á°í Çϰŵç¿ä.. -_-;
¾Æ·¡Ã³·³ ¸¸µé¾ú´Âµ¥¿ä..
>> °æ»óºÏµµ (/output/0) <<
Æ÷Ç׽à (/output/0/2)
>> ÀÎõ±¤¿ª½Ã (/output/3) <<
cannot mkdir File exists at try.pl line 102.
ÀÌ·¸°Ô Áß°£¿¡ ¸¸µé´Ù°¡ °è¼Ó °°Àº°Í¸¸ ¸¸µé´Ù ²÷°Ü¹ö·Á¿ä
¾î¶»°Ô ÇؾßÇϳª¿ä? mkdir() ÇÔ¼ö°¡ ¹®Á¦ÀÎÁö.. ¾Æ´Ï¸é È£ÃâÇÏ´Â °÷ÀÌ ¹®Á¦ÀÎÁö ¸ð¸£°Ú½À´Ï´Ù.
¾î¶»°Ô ¼öÁ¤Çϸé ÁÁÀ»±î¿©?
my %all = ();
open (fp, "data.txt");
while (<fp>) {
chomp;
s/^\s*"//g;
s/"\s*$//g;
s/\s*"\s*,\s*"\s*/","/g;
@arr = split( /","/,$_);
$all{ $arr[6] }{ $arr[7] }{ $arr[8] } = 1;
}
close fp;
my %dir = ();
my $count = 0;
my %addr1 = ();
#print ">>Top (output/) <<\n";
foreach $k1 ( keys %all )
{
$addr1{$k1} = 1;
$dir{ $k1 } = $count++;
my %addr2 = ();
$sub1 = $all{$k1};
#print ">> $k1 (/output/$dir{$k1}) <<\n";
foreach $k2 ( keys %$sub1 )
{
$addr2{$k2} = 1;
$dir{ $k2 } =$count++;
my %addr3 = ();
$sub2 = $sub1->{$k2};
makedir();
#print ">> $k1 > $k2 (/output/$dir{$k1}/$dir{$k2}) <<\n";
foreach $k3 ( keys %$sub2 )
{
$dir{ $k2 } = $count++ ;
$addr3{$k3} = 1 ;
#print "$k3 (/search?addr1=$k1&addr2=$k2&addr3=$k3)";
$dir2= $dir{$k2};
$dir1= $dir{$k1};
# makedir ();
}
# print "\n\n";
#print "$k2 (/output/$dir{$k1}/$dir{$k2})";
#open ( fp, ">$dir{$k1}") || die "failed opening. \n";
#foreach $k2 ( keys %$sub1){
#print fp <<END_HTML;
#<a href =$dir{$k2}> $k2 </a><br>
#END_HTML
# }
# close fp;
}
# print "\n\n";
#print "$k1 (/output/$dir{$k1})\n";
#foreach $k1 (keys %all){
open ( fp, ">index.htm") || die "failed opening.\n";
foreach $k1 (keys %all){
print fp <<END_HTML;
<a href =$dir{$k1}/index.htm> $k1 </a><br>
END_HTML
}
close fp;
}
sub makedir {
mkdir ("$dir1",0777) || die "cannot mkdir $!";
}