Next | Trivial Utilities | 153 |
foreach $file (@ARGV) {
next unless -f $file;
next if -l $file;
unless (open IN, "< $file") {
warn "Couldn't open file `$file' for reading: $!;
skipping.\n";
next;
}
unless (unlink $file) {
warn "Couldn't remove file `$file': $!; skipping.\n";
next;
}
unless (open OUT, "> $file") {
warn "Couldn't open file `$file' for writing: $!;
skipping.\n";
}
The interesting feature here is that the program unlinks an open file
Another thing to note: if open OUT fails, the message is lost
Oops
One thing that continually surprised me as I wrote this class:
A lot of my personal utilities are really shoddily written
Code I do for paying clients is a lot better, honest
Next | Menu | Copyright © 2012 M. J. Dominus |