in reply to Deleting a file after it runs?
when run gives:#!/usr/bin/perl -w open(INIT, ">doit"); while (<INIT>) { printf "%s\n", $_; } close INIT;
Filehandle INIT opened only for output at init.cgi line 3.
How about this for an even shorter solution? -- since Perl reads the entire file into memory before compilation, by runtime, the file is no longer necessary. Hence, you can do it like this:
Now:#!/usr/bin/perl -w unlink $0; # Delete myself! print "Still here!\n"; # Prove that script executes okay # Rest of code follows ...
% init.cgi
Still here!
% ls init.cgi
ls: init.cgi: No such file or directory
|
|---|