getting error "Use of uninitialized value in concatenation (.) or string" what this?
-
hi i am getting error as: Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. during runtime and the output looks like this: Multiplex server running on port 4444... Created thread 1 for new client 10.168.1.2:3233 Use of uninitialized value $_ in scalar chomp at ./iothread.pl line 66, line 1. 1005874632400418 1234 login Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. 10895 Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, line 1.
#!/usr/bin/perl
iothreadserv.pl
use warnings;
use strict;
use integer;BEGIN
{
use Config;
die "No thread support!\n" unless $Config{'usethreads'};
}use Thread;
use IO::Socket;
use DBI;
use DBD::mysql;Autoflushing on
$| = 1;
my $port = 4444;
my $server = IO::Socket->new(
Domain => PF_INET,
Proto => 'tcp',
LocalPort => $port,
Listen => SOMAXCONN,
Reuse => 1,
);die "Bind failed: $!\n" unless $server;
print "Multiplex server running on port $port...\n";while (my $connection = $server->accept)
{
my $name = $connection->peerhost;
my $port = $connection->peerport;
my $thread = new Thread(\&connection, $connection, $name, $port);
print "Created thread ",$thread->tid," for new client $name:$port\n";
$thread->detach;
}
exit;child thread - handle connection
sub connection
{
my ($connection, $name, $port) = @_;
$connection->autoflush(1);
#############################my sql connect###############################
my $platform = "mysql";
my $database = "project";
#my $host = "localhost";
#my $port = "3306";
my $user = "root";
my $pw = "";# DATA SOURCE NAME my $dsn = "dbi:mysql:$database"; # PERL DBI CONNECT my $dbh = DBI->connect($dsn, $user, $pw) or die "cannot connect to database"; #######################################################################33 print $connection "You're connected to the server!\\n"; my $client = <$connection>; chomp; # ($client); #while (<$connection>) { if ($client =~ /::login/) { print $connection "Login Initiated\\n"; my $rand = int(rand(100000)); print $connection "Your rand number : $rand"; #$client =~ s/(\[\\$\\@\\\\\])/\\\\$1/mg; ##escape all $, @ and \\ #$client = quotemeta $client; my @recv\_string = split /::/ , $client; foreach (@recv\_string) { print "$\_ \\n"; } #next line inje
-
hi i am getting error as: Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. during runtime and the output looks like this: Multiplex server running on port 4444... Created thread 1 for new client 10.168.1.2:3233 Use of uninitialized value $_ in scalar chomp at ./iothread.pl line 66, line 1. 1005874632400418 1234 login Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. 10895 Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, line 1.
#!/usr/bin/perl
iothreadserv.pl
use warnings;
use strict;
use integer;BEGIN
{
use Config;
die "No thread support!\n" unless $Config{'usethreads'};
}use Thread;
use IO::Socket;
use DBI;
use DBD::mysql;Autoflushing on
$| = 1;
my $port = 4444;
my $server = IO::Socket->new(
Domain => PF_INET,
Proto => 'tcp',
LocalPort => $port,
Listen => SOMAXCONN,
Reuse => 1,
);die "Bind failed: $!\n" unless $server;
print "Multiplex server running on port $port...\n";while (my $connection = $server->accept)
{
my $name = $connection->peerhost;
my $port = $connection->peerport;
my $thread = new Thread(\&connection, $connection, $name, $port);
print "Created thread ",$thread->tid," for new client $name:$port\n";
$thread->detach;
}
exit;child thread - handle connection
sub connection
{
my ($connection, $name, $port) = @_;
$connection->autoflush(1);
#############################my sql connect###############################
my $platform = "mysql";
my $database = "project";
#my $host = "localhost";
#my $port = "3306";
my $user = "root";
my $pw = "";# DATA SOURCE NAME my $dsn = "dbi:mysql:$database"; # PERL DBI CONNECT my $dbh = DBI->connect($dsn, $user, $pw) or die "cannot connect to database"; #######################################################################33 print $connection "You're connected to the server!\\n"; my $client = <$connection>; chomp; # ($client); #while (<$connection>) { if ($client =~ /::login/) { print $connection "Login Initiated\\n"; my $rand = int(rand(100000)); print $connection "Your rand number : $rand"; #$client =~ s/(\[\\$\\@\\\\\])/\\\\$1/mg; ##escape all $, @ and \\ #$client = quotemeta $client; my @recv\_string = split /::/ , $client; foreach (@recv\_string) { print "$\_ \\n"; } #next line inje
-
hi i am getting error as: Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. during runtime and the output looks like this: Multiplex server running on port 4444... Created thread 1 for new client 10.168.1.2:3233 Use of uninitialized value $_ in scalar chomp at ./iothread.pl line 66, line 1. 1005874632400418 1234 login Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. 10895 Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, line 1.
#!/usr/bin/perl
iothreadserv.pl
use warnings;
use strict;
use integer;BEGIN
{
use Config;
die "No thread support!\n" unless $Config{'usethreads'};
}use Thread;
use IO::Socket;
use DBI;
use DBD::mysql;Autoflushing on
$| = 1;
my $port = 4444;
my $server = IO::Socket->new(
Domain => PF_INET,
Proto => 'tcp',
LocalPort => $port,
Listen => SOMAXCONN,
Reuse => 1,
);die "Bind failed: $!\n" unless $server;
print "Multiplex server running on port $port...\n";while (my $connection = $server->accept)
{
my $name = $connection->peerhost;
my $port = $connection->peerport;
my $thread = new Thread(\&connection, $connection, $name, $port);
print "Created thread ",$thread->tid," for new client $name:$port\n";
$thread->detach;
}
exit;child thread - handle connection
sub connection
{
my ($connection, $name, $port) = @_;
$connection->autoflush(1);
#############################my sql connect###############################
my $platform = "mysql";
my $database = "project";
#my $host = "localhost";
#my $port = "3306";
my $user = "root";
my $pw = "";# DATA SOURCE NAME my $dsn = "dbi:mysql:$database"; # PERL DBI CONNECT my $dbh = DBI->connect($dsn, $user, $pw) or die "cannot connect to database"; #######################################################################33 print $connection "You're connected to the server!\\n"; my $client = <$connection>; chomp; # ($client); #while (<$connection>) { if ($client =~ /::login/) { print $connection "Login Initiated\\n"; my $rand = int(rand(100000)); print $connection "Your rand number : $rand"; #$client =~ s/(\[\\$\\@\\\\\])/\\\\$1/mg; ##escape all $, @ and \\ #$client = quotemeta $client; my @recv\_string = split /::/ , $client; foreach (@recv\_string) { print "$\_ \\n"; } #next line inje
Is this still open? It was posted a while ago. If so, to get started, what are some of the other data points? 1. does "You're connected ...\n"; print? 2. have you tried to insert a print statement before the chomp to see what is in $_; 3. have you tried to put something in $_ to see if the error is suppressed. 4. is there anything in $ref before the print of its fields? 5. does a visual inspection of the MySQL database with your database admin tools show that row should exist? 6. what about some logic to catch this before it croaks? 5. have you tried the Perl debugger with -d on the script. As you know it has watch and break features. If it is web app you may still get enough from running it in console mode. dpminusa
"Coding for fun and profit ... mostly fun"