There is a lot in your script which I would do differently and there is a lot in there which is irrelevant for your problem. However, this SSCCE shows that the logic in your loop, however inefficient, does create a match.
#!/usr/bin/perl use strict; use warnings; my $user = 'foo'; my $pass = 'bar'; my @upd = ( 'abc|abc|xyz|xyz', 'foo|bar|xyz|xyz', 'baz|quux|xyz|xyz' ); my $good = 0; foreach my $line (@upd) { my ($d_line) = split (/\n/, $line); my ($username, $password, $user_pass, $active) = split (/\|/, $d_l +ine); print "Testing '$username' and '$password'\n"; next if $username ne $user; $good = 1 if $username eq $user and $password eq $pass; } print "Good is '$good', should be '1'\n";
This suggests that either you are not processing the form fields correctly or as has already been suggested you are not filling the @upd array correctly (or it doesn't contain what you think it does).
Notice how I've used strict and warnings - they are there to help. See the rest of the Basic Debugging Checklist for more ways to help solve your problem.
🦛
In reply to Re: amateur at Perl need help with small script
by hippo
in thread amateur at Perl need helpwith small script
by jpys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |