#!/usr/bin/perl use CGI qw(:standard); $testUsername = param("username"); $testPassword = param("password"); open (FILE, "password.txt") || die "File cannot be opened"; while($line = ) { chomp $line; # removes carriage return ($username, $password) = split(", ", $line); if ($testUsername eq $username) { $userVerified = 1; if ($testPassword eq $password) { $passwordVerified = 1; last; # go to the last line }}} close (FILE); print "Content-type: text/html\n\n"; print "\n\n”; if ($userVerified &&$passwordVerified) { accessGranted(); } elsif ($userVerified && !$passwordVerified) { wrongPassword(); } else {accessDenied(); } sub accessGranted { print "Permission has been granted, $username."; } sub wrongPassword { print "You entered invalid password."; } sub accessDenied { print "You have been denied access to the server."; }