in reply to Re: Accessing a file from the perl
in thread Accessing a file from the perl
Your main problem is that you're checking ne
if($name ne $user) {
so, unless every entry in the USERNAME file holds the name in question, this will match and quit with ERR.
Also, your way of reading the file
while(<USERNAME>) # reads first entry { my @newusername = <USERNAME>; # reads remaining entries foreach $name (@newusername) ...
skips the first entry for the comparison...
Try something like this:
... my $found; while (my $name = <USERNAME>) { if ($name eq $user) { $found = 1; last; } } unless ($found) { print $client_socket "ERR\n"; ... exit; } print $client_socket "ACK\n";
And either chomp both $user and $name, or none. As you have it, $name has a trailing \n, while $user hasn't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Accessing a file from the perl
by abcdefg (Acolyte) on Jan 12, 2012 at 00:03 UTC | |
by Eliya (Vicar) on Jan 12, 2012 at 00:11 UTC | |
by abcdefg (Acolyte) on Jan 12, 2012 at 00:22 UTC |