geoprocessing using Perl in Arc10

614
4
02-24-2011 06:24 AM
markdenil
Regular Contributor II
Our organization has a large number of scripts written in Perl, and in looking into moving to 10 I have found some issues with creating a geoprocessor. It does not help that I am not very familair with Perl.

Specifically, the line:
my $gp = Win32::OLE->new("esriGeoprocessing.GpDispatch.1") || die $!;
returns the error:
Win32::OLE(0.1709) error 0x80040111: "ClassFactory cannot supply requested class" at C:\...\TestPerl.pl line 6

I realize that GpDispatch.1 is rather old fashioned: I have not been using it in my Python scripting for some time. However, I would like to be able to get the existing Perl scripts working so as to avoid rewriting the whole of every existing script.

How does one create a geoprocessor in Arc 10 using Perl?
0 Kudos
4 Replies
GeraldReiter
New Contributor
Till ArcGIS 10 my perl-scripts worked well with win32::OLE.
As in the documentation to ArcGIS 10 it still says that you can use the geoprocessor with perl, i wonder whats wrong and if we could get an working example how to use the geoprocessor.
It would be hard to rewrite all the code on the webserver and change from perl to python.

regards
0 Kudos
markdenil
Regular Contributor II
Rewriting all our Perl production scripts in Python for Arc10 is exactly what we have had to do.
0 Kudos
JasonScheirer
Regular Contributor II
You'll needs to bootstrap the Perl process to consume ArcObjects by LoadLibrarying the AppInitializerLib.dll in the %ARCGISINSTALL%\bin into memory before it will work in 10. You should be able to accomplish this using either FFI or DynaLoader from CPAN.
0 Kudos
JasonScheirer
Regular Contributor II
As a followup, this works for me:

package LoadGPDispatch;

use strict;

use Win32;
use Win32::OLE;

my %RegHash;
use Win32::TieRegistry( TiedHash => \%RegHash );
my $installKey = $RegHash{"HKEY_LOCAL_MACHINE\\Software\\ESRI\\Desktop10.0\\CoreRuntime"};
my ( $installDir, $type ) = $installKey->GetValue("InstallDir");

my $DLLName = "$installDir\\bin\\AppInitializerLib.dll";

Win32::LoadLibrary($DLLName) || die $!;
my $dispatch = Win32::OLE->new("esriGeoprocessing.GpDispatch.1") || die $!;

print "Success.\n";
0 Kudos