in reply to IO::Compress::Gzip file close issues

Under the hood IO::Compress::Gzip only uses Perl IO. It does use an extarnal library for the compression, but not for the IO.

That means that once this line of your script has been run

gzip $archfile => "$archfile.gz", AutoClose

the file referenced by $archfile will have been closed. What is the value of $! when unlink fails?

Also, does any other process have $archfile open? You cannot delete a file on windows if a proces has it open.

Replies are listed 'Best First'.
Re^2: IO::Compress::Gzip file close issues
by Paul.Unix (Novice) on Jul 27, 2016 at 08:50 UTC
    The $! is "Permission denied". The second unlink after 2 seconds sleep succeeds. First I did not check on the unlink status and the same issue was with moving the newly created .gz file. I noticed that if the move of the .gz file failed also the unlink had failed. That is why it seems to me that the file close is not completed after the gzip yet.