in reply to Accessing a file from the perl

Your code isn't properly formatted, so it's not easy to see what you're trying to post. But you don't seem to be stripping the line break characters from the lines you read from the file.

Replies are listed 'Best First'.
Re^2: Accessing a file from the perl
by abcdefg (Acolyte) on Jan 11, 2012 at 23:22 UTC

    Did you mean to say adding a chomp function after reading the file,like below:

    $user = <$client_socket>; chop($user); #remove the \n print "$prefix USER = $user\n"; unless (open (USERNAME, "username")) { print "ERROR:Cannot open username file.\n"; exit(1); # ERROR } while(<USERNAME>) { my @newusername = <USERNAME>; chomp($newusername); foreach $name (@newusername) { if($name ne $user) { print $client_socket "ERR\n"; print "$prefix ERROR: user $user not permitted to use +this mode. Exiting.\n"; close(USERNAME); exit(1); } } } #else, continue print $client_socket "ACK\n"; # approve the user. close(USERNAME);