#!/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;

