#!/usr/bin/perl

# perl script to maketag(and emaketag)
# on/off の選択肢は tagfile.dkc を使うので jnl1/wnn1 あたりは手動で
# 調整が必要

use Cwd;
$dir = cwd();
(@path) = split(/\//, $dir);
$here = $path[$#path];  # last element of path list
$discfile = "disk".$here;

if ( -f $discfile ){
    rename $discfile, $discfile.".old";
}

$tagfile = "tagfile";
if ( -f $tagfile ){
    rename $tagfile, $tagfile.".old";
}

open(SESAME, "ls *.tgz |");
@files = <SESAME>;
close(SESAME);
for $i ( 0 .. $#files){
    $files[$i] =~ s/\.tgz\n//;
}

open (OUT, ">$discfile");
print OUT "CONTENTS: @files\n";

for $i ( 0 .. $#files) {
    $tmpname = $files[$i].":";
    for ($j=0; $j<11; $j++){
	printf OUT ("%-9.9s \n", $tmpname);
    }
}
close(OUT);

open (OUT, ">$tagfile");
for $i ( 0 .. $#files){
    $tmpname = $files[$i].":";
    printf OUT ("%-9.9s \n", $tmpname);
}



