$user = <$client_socket>; chomp($user); #remove the \n print "$prefix USER = $user\n"; unless (open (USERNAME, "username")) { print "ERROR:Cannot open username file.\n"; exit(1); # ERROR } my $found; while(my $newusername = <USERNAME>) { chomp($newusername); if($newusername eq $user) { $found = 1; last; } unless ($found) { print $client_socket "ERR\n"; print "$prefix ERROR: user $user not allowed Exiting. +\n"; close(USERNAME); exit(1); } } #else, continue print $client_socket "ACK\n"; # approve the user. #print "user $user is allowed."; close(USERNAME);
I tried what you said as above but still it got same problem..still its not goin on else part where user is approved.
In reply to Re^3: Accessing a file from the perl
by abcdefg
in thread Accessing a file from the perl
by abcdefg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |