could some one please help
i am taking a internet feed and wish to split it up into a mysql database
it is a real time comma deliminated fields with one record per line
or any example would be appriciated
this is as far as can go but figuring out how to get it from the socket to
variables is where i get stuck
#!/usr/bin/perl -w
$remote_host = "linus.chemeketa.edu";
#$remote_host = "www.aprs.net";
#$remote_host = "www.wa4dsy.net";
#$port = "1313";
$port = "10152";
#$port = "14579";
$dsn = "track";
$user = "network";
$password = "me";
use :: dbi;
use IO::Socket;
$s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$remote_host",
PeerPort => "$port",
)
or die "cannot connect to $port at $remote_host";
while ( <$s> ) { print }
#First you need to load the DBI module:
use strict;
#(also adding use strict; is recommended). Then you need to connect to your
data source and get a handle for that connection:
$dbh = DBI->connect($dsn, $user, $password,
{ RaiseError => 1, AutoCommit => 0 });
use::dbi
my $sth = $dbh->prepare(q{
INSERT INTO track (callsign,id,lat,lon,msg) VALUES (?,?,?,?,?)
}) || die $dbh->errstr;
while (<>) {
chop;
my ($callsign,$id,$lat,$lon,$msg) = split /,/;
$sth->execute($callsign,$id,$lat,$lon,$msg) || die $dbh->errstr;
}
$dbh->commit || die $dbh->errstr;
regards
David
[EMAIL PROTECTED]
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl