somehow my post screwed up here it is in it's entirety.

could i respectfully request help, i am totaly lost as to how to format this code 
as well as only been with mysql & perl for 2 weeks.
i am trying to take a real time internet tcp feed that is a comma deliminated row 
and input into fields in a mysql database
my attempt although possibly flawed all over the place is listed here :-

=== code ====
#!/usr/bin/perl -w

#for test using socket input from 

$remote_host = "linus.chemeketa.edu";

$port = "10152";

$hostname = '127.0.0.1'; # localhost

$portdb ="3306"; # default mysql port

$database = "track"; # database name

$user = "david"; # database user name

$password = "12345"; # database password

$table ="trackpos"; # database table 

use strict;

use DBI;

use DBD::mysql; 

use IO::Socket;

my %serial_port_buffers; # Used for buffering input from each port.



$s = IO::Socket::INET->new(

Proto => "tcp",

PeerAddr => "$remote_host",

PeerPort => "$port",

)

or die "Cannot connect to $port at $remote_host : $@\n";

# output print testing 

# for test this line produces text output correctly works ok 

#while (<$s>) {print} # for testing socket only

#end of first hurdle

#........................................................

#now add in database and connect the two together !

# read only the socket and put socket output split by comma's into database variables

# and put into database tables , seems easy enough how wrong can i get !.

#$dbh = DBI->connect("DBI:mysql:$database:$hostname:$portdb",

# $user, $password,

# { RaiseError => 1, AutoCommit => 0 });


# my $sth = $dbh->prepare(q{

# INSERT INTO $table (callsign,id,lat,lon,msg) VALUES (?,?,?,?,?)

# }) || die $dbh->errstr;

while ( <$s> ) {

$line = $s->getc();

chop;

my ($callsign,$id,$lat,$lon,$msg) = split /,/;

print "callsign is-,$callsign\n";

print "id is-,$id\n";

print "lat-,$lat\n";

print "lon-,$lon\n";

print "msg-,$msg\n"


# $sth->execute($callsign,$id,$lat,$lon,$msg) || die $dbh->errstr;

}

# $dbh->commit || die $dbh->errstr;


# $dbh ->close


#end
======== end code ======

all help is very much appriciated 

Kind regards
David Armstrong G0JQO ( UK)
[EMAIL PROTECTED] 

Reply via email to