in reply to changing password

Make sure that your web server can read and write the file that you are using for passwords.

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. :)

Leonid Mamtchenkov aka TVSET

Replies are listed 'Best First'.
Re: Re: changing password
by Zaxo (Archbishop) on Sep 25, 2003 at 16:13 UTC

    This solution needs file locking, with attention to race conditions. You probably don't want to prevent multiple instances from running in cgi, so you need to worry about simultaneous requests clobbering one another's work.

    After Compline,
    Zaxo

Re: Re: changing password
by bory (Beadle) on Sep 25, 2003 at 09:02 UTC
    Thank you very much! It works ok!Now I will rewrite it in a compact way!
      I got to ask this! Why do you write an exclaimation mark after each sentence! Are you surprised by everything you say!

      Abigail!

        No, I'm not surprised. Sorry if this bother you.Thank you for understanding me.