in reply to Reading from multi line file -> CGI.pm

Your problem here is not due to CGI.pm. while does not set $_. Plus I think you're forgetting to get rid of the newline. Try this instead:
while (chomp($_ = <FILE>)) { do stuff; }
Update - I'm crazy. while does set $_, but I customarily chomp in the fashion above and I guess I forgot why. :-(
if ($user eq $q->param('ueq &encrypt_pass) {

The above code shouldn't compile. The foreach after it is also completely unnecessary (no sense looping over 1 value). Maybe it ought to look something like:

my $user = $q->param('username'); my $pass = $q->param('password'); verify($user, $pass) or die "No user or password incorrect"; sub verify { my ($ck_user, $ck_pass) = @_; open FH, $user_file" or die "Can't open file, $!"; while (chomp($_=<FH>)) { my ($user, $pass) = split '\|'; if ($user eq $ck_user) { if ($pass ne crypt(ck_pass)) { return 0; } else { return 1; } } } return 0; }
Adjust the return values to suit the logic of your program. I assume that at a minimum you might like to know if the user exists in the user list and whether or not their password is correct.

Replies are listed 'Best First'.
Re: Re: Reading from multi line file -> CGI.pm
by chromatic (Archbishop) on Jan 02, 2003 at 22:08 UTC

    Have you noticed that skips the last line of files that don't end with $\? Be very careful about the return value of chomp.

      I confess to knowing about that particular pitfall and ignoring it. I am a much lazier programmer in Perl than I am in any other language (other than sh/ksh).