Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. getting error "Use of uninitialized value in concatenation (.) or string" what this?

getting error "Use of uninitialized value in concatenation (.) or string" what this?

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
databaseperlmysqlsysadminhelp
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parinay Bansal
    wrote on last edited by
    #1

    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
    
    J D 2 Replies Last reply
    0
    • P Parinay Bansal

      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
      
      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      Which is line 86?

      1 Reply Last reply
      0
      • P Parinay Bansal

        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
        
        D Offline
        D Offline
        dpminusa
        wrote on last edited by
        #3

        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"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups