use POSIX qw(strftime);
use Socket;

# To Elliot, With Love

$filename = "alogfile";

# Send to this host:
$host = 'betelgeuse.theinternetco.net';
# Over UDP
$proto = getprotobyname('udp');
# to the syslog port, looked up in /etc/services
$port = getservbyname('syslog', 'udp');
socket(SOCKET, PF_INET, SOCK_DGRAM, $proto);  
$hisiaddr = inet_aton($host)    || die "unknown host";
$hispaddr = sockaddr_in($port, $hisiaddr);

open(f, $filename) or die "Couldn't open log file ".$filename;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat(f);
seek(f, $size, 0);
while(1) {
	($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat(f);
	if($size > tell(f)) { # is there more?
		$line = <f>; # Read it
		chomp($line); 
		# Adds timestamp to message -- if file contains timestamps, modify to suit
		# uses priority+facility 13. I'm guessing here -- if you need to set priority and facility, fuck with it. Might have to read source, the RFC, or network dumps of working log messages to get the number you want.
		$message = "<13>[remote time:".strftime("%b %d %T", localtime())."] ".$line;
		# print to stdout so you can watch it tick. Remove for production use
		print($message." log position: ".tell(f)." out of ".$size."\n");
		# Send by UDP. Unreliable, but that's UDP for you.
		send(SOCKET, $message, 0, $hispaddr);
	}
	# Waait a sec. Hold it.. hold it .... okay now.
	sleep 1;
}
