
kencl
User
May 27, 2000, 1:29 AM
Post #3 of 4
(214 views)
|
The syntax of the conditional expression should not contain quotes, and you need to use "&&" instead of "and". This is how it should look: (($username ne $usrname) && ($password ne $pwd)); Note that $usrname and $pwd are undefined initially, and I'm not sure if this will cause a problem. I would guess that (UNDEFINED ne ANYDEFINEDANYTHING) would return true, but I'd test that assertion before relying on it. I'd do it like this: $key = $username.":".":".$password; @Valid = grep(/^$key/, @data); ($usrname, $pwd, $location) = split(/::/, $Valid[0]); chomp($location); print "Location: $location\n\n"; Alternatively: foreach $line (@data) { chomp($line); ($usrname, $pwd, $location) = split(/::/, $line); last if (($username eq $usrname) && ($password eq $pwd)); } print "Location: $location\n\n"; The second way is probably better since it stops looking as soon as it finds a match. The grep function above works through every line in @data. Good luck!
|