Next Trivial Utilities 154

unrecv: in-place editing

     unless (open IN, "< $file") {
       warn "Couldn't open file `$file' for reading: $!; skipping.\n";
       next;
     }
     unless (rename $file, "$file.$$.tmp") {
       warn "Couldn't rename file `$file': $!; skipping.\n";
       next;
     }
     unless (open OUT, "> $file") {
       warn "Couldn't open file `$file' for writing: $!; skipping.\n";
       rename "$file.$$.tmp", $file 
           or die "Couldn't restore $file.$$.tmp to $file: $!;
            ABORTING";
     }
     ...
     unlink "$file.$$.tmp";
        local $^I = "";
        while (<>) {
          ...
        }


Next Menu Copyright © 2012 M. J. Dominus