Next Lightweight Databases 13

Copy With Changes

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


Next Copyright © 2003 M. J. Dominus