in reply to Re: What is the best way to delete a file in windows using Perl?
in thread What is the best way to delete a file in windows using Perl?
or on the web: unlink
Update: I cleaned up and fixed the OP's code:
sub Check_request_file { my ($file_to_check) = @_; local *_; # Protect caller's $_. open(local *FILE, '<', $file_to_check) or die("Unable to open SPROC file $file_to_check: $!\n"); while (<FILE>) { if (/SPROC\sName\:(?!\s[rR]eception)/) { close(FILE); # So we can delete it unlink($file_to_check) or die("Unable to delete SPROC file $file_to_check: $!\n"); return; # Optional, since <FILE> will # return false for a closed file. } } }
|
|---|