Ok, so i have this code:
use IO::Socket::INET;
my $sock = new IO::Socket::INET (
LocalPort => 6547,
Listen => 10,
Proto => 'tcp',
Reuse => 1
);
print "Waiting For Requests!!\n";
while(my $client = $sock->accept()){
print "Connection!\n";
my $blah=<$client>;
handle($blah,$client);
$client->close();
}
sub handle{
my ($data,$client) = @_;
chomp($data);
my ($command, $param) = split '<div>',$data;
print "$command\n";
if($command == 'start'){
print $client "Welcome to the game: $param\n";
}
if($command == 'newUser'){
print $client "$param Has been added to the database!!\n";
}
}
So, if i send "start" to the server, it will return "Welcome to the game: ", but if i send "newUser<div>username", the server returns "Welcome to the game: username" and sometimes it returns "username has been added to the database, and sometimes i'll return both!!!
I put that print statment before the conditionals to see if $command was right, and yes it is, it prints the right parameter i send.
Please HELP! thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.