Next Lightweight Databases 14

Copy With Changes

        sub delete_user {
          my ($file, $target_user) = @_;
          open my $rfh, "<", $file or die ...;
          open my $wfh, ">", "$file.tmp" or die ...;
          while (<$rfh>) {
            my ($user) = split /:/;
            print $wfh unless $user eq $target_user;
          }
          close $rfh or die ...; 
          close $wfh or die ...;
          rename "$file.tmp", $file or die ...;
        }


Next Copyright © 2003 M. J. Dominus