Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Accessing a file from the perl

by tobyink (Canon)
on Jan 11, 2012 at 22:55 UTC ( #947450=note: print w/replies, xml ) Need Help??

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);

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://947450]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-06-06 09:44 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.