#!/usr/bin/perl -w

$prefix = "./newlog/";
if (-d $prefix){
	mkdir $prefix;
}

@exception = ();

foreach $file_name (@ARGV){

	open(READFILE, "<".$file_name);
	open(WRITEFILE, ">".$prefix.$file_name);

	my @records = <READFILE>;
	foreach $line (@records){
		$temp = $line;
		$temp =~ s/\\"/-/g;
		$temp =~ s/ ".*?" / string /g;
		$temp =~ s/\s+$//;
		$temp =~ s/ ".*?"$/ string /g;
		my @array = split(/\s+/, $temp);
		my $length = @array;
		#print $line ." -> " . $temp . " : " . $length ."\n";
		if ( $length == 8){
			chomp($line);
			$line = $line . ' "-" "-"'."\n";	
		}
		if ( $length != 8 && $length != 10 && $length != 0){
			push @exception, $line;
		}
		print WRITEFILE $line;	
	}
	close(READFILE);
	close(WRITEFILE);

	my $len = @exception;
	if ($len != 0){
		print "Warning! the number after line splits is not 8 and 10. : " . $file_name ."\n";
		# exception line display
		foreach $val (@exception){
			print $val;
		}
	} else {
		my $num = @records;
		print "Success!: " . "file=" . $file_name . ", record=" .$num . "\n";
	}
}
