PERL: wait for process to complete

I'm using PERL on windows NT to try to run an extract of data. I have multiple zip files in multiple locations. I am extracting "*.t" from zip files and subsequently adding that file to one zip file so when the script is complete I should have one zip file with a whole bunch of ".t" files in it.

The problem comes after I extract the ".t" file and try to zip it up again, the file is not yet in the directory so zip cannot find the file. I have commented out the code beneath the zip command while testing the program.
Please help!


###Get generation directory information ###
open(GENDIR, "<gens.txt") or die "Can't open gens.txt $!";
while(<GENDIR>){
	chop($_);
	push(@gendirs,$_)
}	

## Unzip .t file into stage directory ##
for $i (0 .. $#gendirs){  
   	($gennum)=(split /\\G/, $gendirs[$i])[1];
	#print "$gennum\n";
	print "unzip -d \\stage -j $gendirs[$i]\\*.zip *.t\n";
	system("unzip -d \\stage -j $gendirs[$i]\\*.zip *.t");
##zip .t file ##
	system("zip -v -9 \\stage\\vista.zip ${gennum}.t");
	#open(GENS, "<listofGens.dat") or die "Can't open listofGens.dat $!";
	#while(<GENS>){
		#chop($_);
		#if ($_=~/^$gennum\|/){
			#($repname)=(split /\|/)[1];
			#print "$repname\n";
			#print "${gennum}.t";
			#print "\nrename \\stage\\${gennum}.t \\stage\\$repname\n";
			#system("rename stage\\${gennum}.t stage\\$repname");
			#last;
		#} 
		
	#}
	#close(GENS);
}





#open(GENS, "<listofGens.dat") or die "Can't open listofGens.dat $!";
#while(<GENS>){
#}

i have to ask a couple of questions.

1) if you comment out the zip portion do you see the files extracted to the proper directory?

2) why are you trying to zip it back up right after you unzip it? why dont you do all of your unziping then call your zip processes.

3) altho i havent worked with perl on windows i dont think you need to backslash the backslash in this case.

but at this point i would be makeing sure each portion of the script is doing what you want.

start w/ the unzip functions and makesure it is extracting your data to the correct directory.

then work on the zip portion. persaonly i would write 2 functions.

1 that unzips and 1 that zips; and i would do all the unziping first then do the zip.

Thanks for the response. I've figured out the problem, which is not what I thought it was. The issue is that I did not specify the correct directory when zipping the files and thats why the zip program was complaining.

so...

system("zip -v -9 \\stage\\vista.zip ${gennum}.t");

should have been

system("zip -v -9 \\stage\\vista.zip \\stage\\${gennum}.t");

To answer your questions Optimus ( thanks for your suggestions which led me to the problem)...
1) Yes the files were extracted to the directory.
2) This method of zipping the files immediately after unzipping them is purely a space issue. I am dealing with thousands of text files, many of them are around .5GB unzipped. If I were to unzip all of them I would run out of disk space.
3) In my experience with windows and perl, you need either the double backslash or forward slash. There may be other ways to do it that I am not aware of.