# Warning, possible race condition ahead # I need to update this opening a locking! if (!open(FH,"<$passwdFile")) { carp("Cannot open $passwdFile: $!"); return; } flock(FH, 2); if (!exists $self->{CURRENT}{Id}) { while () { if ( /^$Id\:/ ) { push (@cache, "$Id\:$cryptedPass\n") unless $cryptedPass eq ""; $return = 1; } else { push (@cache, $_); } } } close FH; if ($return) { if (!open(FH, ">$passwdFile")) { carp("Cannot open $passwdFile: $!"); return; } flock(FH, 2); while (@cache) { print FH shift (@cache); } } else { if (!open(FH, ">>$passwdFile")) { carp("Cannot open $passwdFile: $!"); return; } flock(FH, 2); print FH "$Id\:$cryptedPass\n" unless $cryptedPass eq ""; $foo = $hash{FOO}; }