use Win32::OLE qw(in with);
use Win32::OLE::Const 'Surfer';
$Win32::OLE::Warn = 3;	# Gives more info on errors

# Create the Surfer object by either taking the already running instance or creating a new one
my $Surfer = Win32::OLE->GetActiveObject('Surfer.Application') || Win32::OLE->new('Surfer.Application');
$Surfer->{'Visible'} = 1;

# Grid a Sample file, change the paths if desired
my $sampleFile = $Surfer->Path."\\Samples\\Demogrid.dat";
my $gridFile = $Surfer->Path."\\Samples\\Demogrid.grd";
$Surfer->GridData({
	DataFile=>"$sampleFile", 
	Algorithm=>srfKriging,
	xCol=>1, 
	yCol=>2, 
	zCol=>3, 
	OutGrid=>"$gridFile"
	});

# Create a contour map on a new document from the grid created above
my $plot = $Surfer->Documents->Add;
$contourMap = $plot->Shapes->AddContourMap("$gridFile");