#!/usr/bin/perl
# 
# A: Zia
# Version: 1.0
# Changlog:
# 25-Nov-2008 - Changed to reflect the latest Turba database. Thanks to David Ehle for pointing that out.
#

$file=$ARGV[0];
$ownerid=$file;
$ownerid=~ s/\.abook//;
open (FILE,"<$file");
while(<FILE>) {
	chomp($line = $_);
	($oalias,$ofirstname,$olastname,$oemail,$onotes) = split('\x7c',$line);
	$oalias =~ s/'//;
	$ofirstname =~ s/'//;
	$olastname =~ s/'//;
	$onotes =~ s/'//;
	$objectid=$ownerid . int(rand(500000)); 
	print "insert into turba_objects (object_id,owner_id,object_alias,object_email,object_firstname,object_lastname,object_notes) values (MD5('$objectid'), '$ownerid', '$oalias', '$oemail', '$ofirstname', '$olastname', '$onotes')\;\n";
}
close FILE;
