Hi,
When I run my program on a linux machine it opens, renames, and unlinks the files as expected. However, when I run it on Windows it will not rename or unlink the files. Since it is opening and reading the files correctly, it seems that the problem is not in the difference between the path name styles.
Here are the relevant parts of the code:
[CODE=perl]
open(INFILE, '<', $the_infile) || die $!;
#read from infile, modify contents
open(OUTFILE, '>', $the_outfile) || die $!;
#print modified contents to outfile
open(ORIG_INFIL E, '>', $original_outfi le) || die $!;
#copy content from INFILE to ORIG_INFILE
unlink("$the_in file");
#Rename the OUTFILE with the same name as the INFILE
rename($the_out file, $the_infile);
close (ORIG_INFILE);
close (INFILE);
close (OUTFILE);
[/CODE]
I'm not sure if it's legal to rename($the_out file, $the_infile) after I've unliked the $the_infile and I also wasn't sure if I had to close (INFILE) after I unlinked it. Even though it works fine on linux, could this possibly cause the problem on windows?
Any suggestions would be greatly appreciated!
Thanks!
When I run my program on a linux machine it opens, renames, and unlinks the files as expected. However, when I run it on Windows it will not rename or unlink the files. Since it is opening and reading the files correctly, it seems that the problem is not in the difference between the path name styles.
Here are the relevant parts of the code:
[CODE=perl]
open(INFILE, '<', $the_infile) || die $!;
#read from infile, modify contents
open(OUTFILE, '>', $the_outfile) || die $!;
#print modified contents to outfile
open(ORIG_INFIL E, '>', $original_outfi le) || die $!;
#copy content from INFILE to ORIG_INFILE
unlink("$the_in file");
#Rename the OUTFILE with the same name as the INFILE
rename($the_out file, $the_infile);
close (ORIG_INFILE);
close (INFILE);
close (OUTFILE);
[/CODE]
I'm not sure if it's legal to rename($the_out file, $the_infile) after I've unliked the $the_infile and I also wasn't sure if I had to close (INFILE) after I unlinked it. Even though it works fine on linux, could this possibly cause the problem on windows?
Any suggestions would be greatly appreciated!
Thanks!
Comment