LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-01-2009, 10:35 AM   #1
haxpak
Member
 
Registered: Jan 2009
Location: India
Distribution: fc9 x86_64
Posts: 35

Rep: Reputation: 15
Use of uninitialized value in concatenation (.) althougth var visible


hi
i am getting error as:
Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, <GEN1> line 1.
during runtime

and
the output looks like this:
Quote:
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, <GEN1> line 1.
1005874632400418
1234
login

Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, <GEN1> line 1.
10895
Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, <GEN1> line 1.
Code:
#!/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 injection possible !! REMOVE IT!!
		my $sth = $dbh->prepare("select * from Temp_ID where TEMP_NO = $recv_string[0]");
		$sth->execute();
		#take only one output row
		my $ref = $sth->fetchrow_hashref();	
#		$sth->finish();
		print "$ref->{'Temp_ID'} $ref->{'CARD_ID'}\n";
		$sth = $dbh->("select PIN from Cards where Card_ID = $ref->{CARD_ID}");
		$sth->execute();
#		$sth->finish();
		
		my $ref2 = $sth->fetchrow_hashref();
		if ($recv_string[1] eq $ref2->{PIN})
			{
			print $connection "PIN verified OK";
			
			}
			
		
	}
	
	if ($client =~ /:logout/)
	{
		print $connection "You are being Logged OUT\n";
	}
	print "Client $name:$port says: $client \n";
      	print $connection "Message received OK\n";
	#	}
	$dbh->disconnect;
	$connection->shutdown(SHUT_RDWR);
}
 
Old 03-01-2009, 04:47 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
http://www.linuxquestions.org/questi...-error-708386/

Follow-ups to in Programming:
http://www.linuxquestions.org/questi...d.php?t=708363
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
STL String: Uninitialized or some null value Ephracis Programming 9 03-04-2008 01:27 PM
files not visible in ftp site (but present in the /var/ftp/folder of the server) dongrila Linux - Newbie 2 12-23-2007 10:09 PM
Bash Concatenation alieas Programming 3 09-04-2006 01:45 PM
cricket - uninitialized value in script imanassypov Linux - Networking 0 03-21-2006 09:19 AM
Test uninitialized variable AMMullan Programming 6 02-12-2004 10:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration