Whiteknight
05-13-2004, 12:52 AM
I'm having some stupid problems with some string functions, for some reason, and i just have been staring at this code for too long now to find my mistakes. here is the code:
open(FILE, $file_location);
$FILE = <FILE>;
print $FILE; #first test
close(FILE);
if ( !($FILE == $test_variable ) )
{
print "value incorrect";
exit;
}
...
now, what i am trying to do is set up a rudimentary password protection here. the $file_location points to a text file with a single line of text, that is a password. the value $test_variable is input from the command line, and is the password that is being tested.
the $file_location is tested for existance prior to this routine.
now, the problem is that every password gets counted as correct, and the program never exits. the only time the program exits is if there is no password, ie the entered string is blank.
if i change the "==" in the if statement to the string operator "eq" then it says that the password is always wrong, and the correct password gets counted as wrong.
any ideas?
open(FILE, $file_location);
$FILE = <FILE>;
print $FILE; #first test
close(FILE);
if ( !($FILE == $test_variable ) )
{
print "value incorrect";
exit;
}
...
now, what i am trying to do is set up a rudimentary password protection here. the $file_location points to a text file with a single line of text, that is a password. the value $test_variable is input from the command line, and is the password that is being tested.
the $file_location is tested for existance prior to this routine.
now, the problem is that every password gets counted as correct, and the program never exits. the only time the program exits is if there is no password, ie the entered string is blank.
if i change the "==" in the if statement to the string operator "eq" then it says that the password is always wrong, and the correct password gets counted as wrong.
any ideas?