in reply to changing password
Also my personal approach to this kind of problems is to read the complete file first, then modify it, and then to write it back. Something along these lines:
open (IN,"<$myfile") or die "open failed for read: $!"; my @lines = <IN>; close (IN); open (OUT, ">$myfile") or die "open failed for write: $!"; foreach (@lines) { chomp; my ($user,$pass) = split(/=/); # Check username if ($user eq $i_user) { # Check password if ($pass eq $i_pass) { # Check the confirmation of the new password if ($i_newpass eq $i_cnewpass) { print OUT "$user=$i_newpass\n"; } } } else { print OUT "$user=$pass\n"; } } close (IN);
These, of course, looks childish, but it's extremely easy to read and follow. If this one works, then you can rewrite it in a more compact way. :)
P.S.: Code is untested of course. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: changing password
by Zaxo (Archbishop) on Sep 25, 2003 at 16:13 UTC | |
|
Re: Re: changing password
by bory (Beadle) on Sep 25, 2003 at 09:02 UTC | |
by Abigail-II (Bishop) on Sep 25, 2003 at 09:19 UTC | |
by bory (Beadle) on Sep 25, 2003 at 09:37 UTC |