open (IN,"<$myfile") or die "open failed for read: $!"; my @lines = ; 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);