sub verify { # open FILE, "$user_file" || die "Can't open user's login files: $!"; # the previous line doesn't obey operator precedence rules # see `perldoc perlop` # as well as it uses "" for nothing.. open FILE, $user_file or die "... $!"; while() { my ($user,$pass)=split(/\|/); # foreach $user($user) { # the previous line does exactly nothing but aliasing $user # to $user, that's really quite useless # See `perldoc perlsyn` # if ($user eq $q->param('ueq &encrypt_pass) { # hmm? i try to guess this might be if( $user eq $q->param('u') ){ # &good; # you're calling a sub and i'm sure you don't know what the # & means and does. See `perldoc perlsub` # Apart from that this routine will sometime return and # you want to go on reading the file then? # } else { &bad; # same problem + you will call 'bad' for every name in the # file that doesn't equal the submitted username. # Is that your intention? } } } close FILE; } #### for each line in the file split up into name and password if the name is the needed name verify the password if it is correct end the loop successfully otherwise cry for help or simply die of error ... if the name doesn't match go to the next line #### while( ){ # = for each line of the file chomp; # (remove trailing newline) my ($name,$pass) = split /\|/; # = split up into name and password if( $name eq $wanted_name ){ # = if the name is the needed name if( $pass eq $submitted_passord ){ # = verify the password # = if it is correct last; # = end the loop successfully } else { # = otherwise die "bastard $name gave me wrong password!\n" # = cry for help or simply die of error ... } } # = if the name doesn't match # go to the next line }