Index: /main/trunk/greenstone2/bin/script/build
===================================================================
--- /main/trunk/greenstone2/bin/script/build	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/build	(revision 24362)
@@ -43,5 +43,4 @@
 use FileHandle;
 use File::Copy;
-use Config; # for getting the perlpath in the recommended way
 
 BEGIN {
@@ -277,6 +276,5 @@
 		#       option was given to build)
 
-		#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-		my $download_cmd = "\"$Config{perlpath}\" -S gsWget.pl -P \"$importdir\" -np -nv";
+		my $download_cmd = "\"".&util::get_perl_exec()."\" -S gsWget.pl -P \"$importdir\" -np -nv";
 		$download_cmd .= " -r -N -l inf -R \"*\\?*\"";
 		$download_cmd .= " -o \"$outfile.download\"" if $use_out;
@@ -328,5 +326,5 @@
 		    # copy download_dir and all it contains to the import directory
 		    #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-		    my $download_cmd = "\"$Config{perlpath}\" -S filecopy.pl";
+		    my $download_cmd = "\"".&util::get_perl_exec()."\" -S filecopy.pl";
 		    $download_cmd .= " -collectdir \"$collectdir\"" if $collectdir =~ /\w/;
 		    $download_cmd .= " -site \"$site\"" if $site =~ /\w/;
@@ -468,5 +466,5 @@
 
     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-    my $import_cmd = "\"$Config{perlpath}\" -S import.pl";
+    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
     $import_cmd .= " -out \"$outfile.import\"" if $use_out;
     if ($append) {
@@ -515,5 +513,5 @@
 
     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-    my $build_cmd = "\"$Config{perlpath}\" -S buildcol.pl";
+    my $build_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl";
 
     my $removeold = 1;
Index: /main/trunk/greenstone2/bin/script/full-buildcol.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/full-buildcol.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/full-buildcol.pl	(revision 24362)
@@ -32,24 +32,13 @@
 BEGIN {
     die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
+	unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
 }
 
 use strict;
-use Config; # for getting the perlpath in the recommended way
+use util;
 
 my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
 
-
-my $buildcol_cmd = "buildcol.pl -removeold $quoted_argv";
-if($ENV{'PERLPATH'}) {
-    # need to ensure that the path to perl is quoted (in case there's spaces in it)
-    if($ENV{'GSDLOS'} =~ m/windows/) {
-	$buildcol_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $buildcol_cmd";
-    } else {
-	$buildcol_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $buildcol_cmd";
-    }
-} else {
-    #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-    $buildcol_cmd = "\"$Config{perlpath}\" -S $buildcol_cmd";
-}
+my $buildcol_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl -removeold $quoted_argv";
 
 my $buildcol_status = system($buildcol_cmd)/256;
Index: /main/trunk/greenstone2/bin/script/full-import.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/full-import.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/full-import.pl	(revision 24362)
@@ -33,23 +33,14 @@
 BEGIN {
     die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
+	unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
 }
 
 use strict;
-use Config; # for getting the perlpath in the recommended way
+use util;
 
 my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
 
-my $import_cmd = "import.pl -removeold $quoted_argv";
-if($ENV{'PERLPATH'}) {
-    # need to ensure that the path to perl is quoted (in case there's spaces in it)
-    if($ENV{'GSDLOS'} =~ m/windows/) {
-	$import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
-    } else {
-	$import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
-    }
-} else {
-    #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-    $import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
-}
+# need to ensure that the path to perl is quoted (in case there's spaces in it)
+my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl -removeold $quoted_argv";   
 
 my $import_status = system($import_cmd)/256;
Index: /main/trunk/greenstone2/bin/script/full-rebuild.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/full-rebuild.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/full-rebuild.pl	(revision 24362)
@@ -39,8 +39,5 @@
 }
 
-
 use strict;
-
-use Config; # for getting the perlpath in the recommended way
 use util;
 
@@ -105,16 +102,6 @@
     my $final_status = 0;
 
-    my $launch_cmd = "";
-    if($ENV{'PERLPATH'}) {
 	# need to ensure that the path to perl is quoted (in case there's spaces in it)
-	if($ENV{'GSDLOS'} =~ m/windows/) {
-	    $launch_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S ";
-	} else {
-	    $launch_cmd = "\"$ENV{'PERLPATH'}/perl\" -S ";
-	}
-    } else {
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$launch_cmd = "\"$Config{perlpath}\" -S ";
-    }
+    my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";    
     
     print "\n";
Index: /main/trunk/greenstone2/bin/script/gsConvert.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/gsConvert.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/gsConvert.pl	(revision 24362)
@@ -47,13 +47,4 @@
     die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
     unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
-
-    if(!$ENV{'PERLPATH'}) {
-	use Config; # for some reason, this can't be a require statement
-	my $full_perl_exec = $Config{perlpath}; #$^X;	
-	require File::Basename;
-	my $perl_path = File::Basename::dirname($full_perl_exec);
-	$ENV{'PERLPATH'} = $perl_path;
-    }
-
 }
 
@@ -63,9 +54,4 @@
 use util;
 use Cwd;
-#use Config; # for getting the perlpath in the recommended way
-# Note: even though this (and other) use statement comes after its
-# usage in BEGIN, the use statement is in fact executed before BEGIN.
-# Doesn't work here for Greenstone 3.
-
 
 # Are we running on WinNT or Win2000 (or later)?
@@ -419,5 +405,5 @@
 	# formulate the command
 	my $cmd = "";
-	my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
+	my $full_perl_path = &util::get_perl_exec();
 	$cmd .= "\"$full_perl_path\" -S ppttohtml.pl ";
 	$cmd .= " \"$input_filename\" \"$output_filestem.html\"";
@@ -453,5 +439,5 @@
 	# formulate the command
 	my $cmd = "";
-	my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
+	my $full_perl_path = &util::get_perl_exec();
 	$cmd .= "\"$full_perl_path\" -S xlstohtml.pl ";
 	$cmd .= " \"$input_filename\" \"$output_filestem.html\"";
@@ -1014,5 +1000,5 @@
     my $cmd = "";
     if ($timeout) {$cmd = "ulimit -t $timeout;";}
-    my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
+    my $full_perl_path = &util::get_perl_exec();
     $cmd .= "\"$full_perl_path\" -S pdftohtml.pl -zoom $pdf_zoom";
     $cmd .= " -c" if ($pdf_complex);
@@ -1089,5 +1075,5 @@
     if ($timeout) {$cmd = "ulimit -t $timeout;";}
     $output_type =~ s/.*\_(.*)/$1/i;
-    my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
+    my $full_perl_path = &util::get_perl_exec();
     $cmd .= "\"$full_perl_path\" -S pdfpstoimg.pl -convert_to $output_type \"$input_filename\" \"$output_filestem\"";
     if ($ENV{'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000) {
Index: /main/trunk/greenstone2/bin/script/gti.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/gti.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/gti.pl	(revision 24362)
@@ -31,12 +31,4 @@
     die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
     unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
-
-    if(!$ENV{'PERLPATH'}) {
-	use Config; # for getting the perlpath in the recommended way
-	my $full_perl_exec = $Config{perlpath}; #$^X;
-	require File::Basename;
-	my $perl_path = File::Basename::dirname($full_perl_exec);
-	$ENV{'PERLPATH'} = $perl_path;
-    }
 }
 
@@ -645,5 +637,5 @@
 
     my $target_filepath = &util::filename_cat($gsdl_root_directory, $target_file);
-    my $perl_exec = &util::filename_cat($ENV{'PERLPATH'}, "perl");
+    my $perl_exec = &util::get_perl_exec();
     my $java_exec = "java";
     if(defined($ENV{'JAVA_HOME'}) && $ENV{'JAVA_HOME'} ne ""){
Index: /main/trunk/greenstone2/bin/script/incremental-buildcol.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-buildcol.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/incremental-buildcol.pl	(revision 24362)
@@ -42,5 +42,4 @@
 no strict 'subs'; # allow barewords (eg STDERR) as function arguments
 
-use Config; # for getting the perlpath in the recommended way
 use util;
 use colcfg;
@@ -92,6 +91,5 @@
 	print STDERR "Unable to use collection \"$collection\" within \"$collect_dir\"\n";
 	exit -1;
-    }	
-
+    }
 
     if (!defined $build_dir) {
@@ -103,16 +101,5 @@
     my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
     
-    my $buildcol_cmd = "buildcol.pl";
-    if($ENV{'PERLPATH'}) {
-	# need to ensure that the path to perl is quoted (in case there's spaces in it)
-	if($ENV{'GSDLOS'} =~ m/windows/) {	
-	    $buildcol_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $buildcol_cmd";
-	} else {
-	    $buildcol_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $buildcol_cmd";
-	}
-    } else {
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$buildcol_cmd = "\"$Config{perlpath}\" -S $buildcol_cmd";
-    }
+    my $buildcol_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl";
 
     # Read in the collection configuration file.
Index: /main/trunk/greenstone2/bin/script/incremental-import-onlyadd.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-import-onlyadd.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/incremental-import-onlyadd.pl	(revision 24362)
@@ -31,5 +31,4 @@
 
 
-
 BEGIN {
     die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
@@ -38,8 +37,5 @@
 }
 
-
 use strict;
-
-use Config; # for getting the perlpath in the recommended way
 use dbutil;
 use util;
@@ -60,5 +56,4 @@
 	exit(-1);
     }
-
 
     my $collection = pop @argv;
@@ -109,21 +104,9 @@
     my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
     
-
-    my $import_cmd = "import.pl";
-    if($ENV{'PERLPATH'}) {
 	# need to ensure that the path to perl is quoted (in case there's spaces in it)
-	if($ENV{'GSDLOS'} =~ m/windows/) {
-	    $import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
-	} else {
-	    $import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
-	}
-    } else {
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
-    }
+    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
 
     if (-e $archiveinf_doc) {
-	$import_cmd .= " -keepold";
-	
+	$import_cmd .= " -keepold";	
     }
     else {
@@ -135,5 +118,4 @@
 
     $import_cmd .= " $quoted_argv \"$collection\"";
-
     
     my $import_status = system($import_cmd)/256;
Index: /main/trunk/greenstone2/bin/script/incremental-import.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-import.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/incremental-import.pl	(revision 24362)
@@ -31,5 +31,4 @@
 
 
-
 BEGIN {
     die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
@@ -38,8 +37,5 @@
 }
 
-
 use strict;
-
-use Config; # for getting the perlpath in the recommended way
 use dbutil;
 use util;
@@ -60,5 +56,4 @@
 	exit(-1);
     }
-
 
     my $collection = pop @argv;
@@ -129,17 +124,6 @@
     my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
     
-
-    my $import_cmd = "import.pl";
-    if($ENV{'PERLPATH'}) {
 	# need to ensure that the path to perl is quoted (in case there's spaces in it)
-	if($ENV{'GSDLOS'} =~ m/windows/) {
-	    $import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
-	} else {
-	    $import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
-	}
-    } else {
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
-    }
+    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
 
     if (defined $manifest) {
Index: /main/trunk/greenstone2/bin/script/incremental-rebuild.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-rebuild.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/incremental-rebuild.pl	(revision 24362)
@@ -39,8 +39,5 @@
 }
 
-
 use strict;
-
-use Config; # for getting the perlpath in the recommended way
 use util;
 
@@ -85,16 +82,6 @@
     my $final_status = 0;
     
-    my $launch_cmd = "";
-    if($ENV{'PERLPATH'}) {
 	# need to ensure that the path to perl is quoted (in case there's spaces in it)
-	if($ENV{'GSDLOS'} =~ m/windows/) {
-	    $launch_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S ";
-	} else {
-	    $launch_cmd = "\"$ENV{'PERLPATH'}/perl\" -S ";
-	}
-    } else {
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$launch_cmd = "\"$Config{perlpath}\" -S ";
-    }
+    my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";    
 
     print STDERR "\n";
Index: /main/trunk/greenstone2/bin/script/mirror.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/mirror.pl	(revision 24361)
+++ /main/trunk/greenstone2/bin/script/mirror.pl	(revision 24362)
@@ -48,5 +48,4 @@
 }
 
-use Config; # for getting the perlpath in the recommended way
 use arcinfo;
 use colcfg;
@@ -117,6 +116,6 @@
 	# run the mirror program from the import directory
 	my  $cmd = "cd $importdir; ";
-	#Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
-	$cmd .= "\"$Config{perlpath}\" -S gsw3mir.pl -cfgfile $etcdir/w3mir.cfg";
+	# need to ensure that the path to perl is quoted (in case there's spaces in it)
+	$cmd .= "\"".&util::get_perl_exec()."\" -S gsw3mir.pl -cfgfile $etcdir/w3mir.cfg";
 	# print "\n$cmd\n";
 	`$cmd`;
@@ -128,5 +127,5 @@
     elsif ((-e "$etcdir/wget.cfg") && (-e "$etcdir/wget.url")) {
 	$ENV{WGETRC} = "$etcdir/wget.cfg";
-	my $cmd = "\"$Config{perlpath}\" -S gsWget.pl --input-file=$etcdir/wget.url --directory-prefix=$importdir";
+	my $cmd = "\"".&util::get_perl_exec()."\" -S gsWget.pl --input-file=$etcdir/wget.url --directory-prefix=$importdir";
 	system($cmd);
     }
Index: /main/trunk/greenstone2/perllib/cgiactions/baseaction.pm
===================================================================
--- /main/trunk/greenstone2/perllib/cgiactions/baseaction.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/cgiactions/baseaction.pm	(revision 24362)
@@ -28,7 +28,6 @@
 
 use strict;
-
+use util;
 use inexport;
-use Config; # for getting the perlpath in the recommended way
 
 our $authenication_enabled = 0;
@@ -434,5 +433,5 @@
     my $gsdl_cgi = $self->{'gsdl_cgi'};
 
-    my $sendmail_command = "\"$Config{perlpath}\" -S sendmail.pl";
+    my $sendmail_command = "\"".&util::get_perl_exec()."\" -S sendmail.pl";
     $sendmail_command .= " -to \"" . $mail_to_address . "\"";
     $sendmail_command .= " -from \"" . $mail_from_address . "\"";
@@ -463,5 +462,5 @@
     $perl_args = "-collectdir \"$collect_dir\" " . $perl_args;
 
-    my $perl_command = "\"$Config{perlpath}\" -S $script $perl_args";
+    my $perl_command = "\"".&util::get_perl_exec()."\" -S $script $perl_args";
 
 
Index: /main/trunk/greenstone2/perllib/cgiactions/buildaction.pm
===================================================================
--- /main/trunk/greenstone2/perllib/cgiactions/buildaction.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/cgiactions/buildaction.pm	(revision 24362)
@@ -36,5 +36,4 @@
 
 use util;
-use Config; # for getting the perlpath in the recommended way
 
 BEGIN {
@@ -139,5 +138,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-import.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -178,5 +177,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-buildcol.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -216,5 +215,5 @@
 	
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-rebuild.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -256,5 +255,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S incremental-import.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -295,5 +294,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S incremental-buildcol.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -334,5 +333,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -404,5 +403,5 @@
 		
 		## my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-		my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl -manifest \"$manifest_filename\" \"$collect\"";
+		my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl -manifest \"$manifest_filename\" \"$collect\"";
 
 		($status,$report) = $self->run_build_cmd($cmd);
Index: /main/trunk/greenstone2/perllib/cgiactions/indexaction.pm
===================================================================
--- /main/trunk/greenstone2/perllib/cgiactions/indexaction.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/cgiactions/indexaction.pm	(revision 24362)
@@ -29,16 +29,9 @@
 
 use strict;
-
+use util;
 use cgiactions::baseaction;
-use Config; # for getting the perlpath in the recommended way
 
 
 @indexaction::ISA = ('baseaction');
-
-
-
-
-
-
 
 # 'a' for action, and 'c' for collection are also compulsorary, and
@@ -133,5 +126,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-import.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -172,5 +165,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-buildcol.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -211,5 +204,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S full-rebuild.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -251,5 +244,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S incremental-import.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -292,5 +285,5 @@
 
     my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
-    my $cmd = "\"$Config{perlpath}\" -S incremental-buildcol.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
@@ -329,5 +322,5 @@
     $self->lock_collection($username, $collect);
 
-    my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl \"$collect\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
 
     my ($status,$report) = $self->run_build_cmd($cmd);
Index: /main/trunk/greenstone2/perllib/g2futil.pm
===================================================================
--- /main/trunk/greenstone2/perllib/g2futil.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/g2futil.pm	(revision 24362)
@@ -15,5 +15,4 @@
 use strict;
 use util;
-use Config; # for getting the perlpath in the recommended way
 
 sub run_cmd_old
@@ -31,5 +30,5 @@
     
     if ($verbosity >= 2) {
-	print "Runing command:\n";
+	print "Running command:\n";
 	print "$cmd\n";
     }
@@ -64,5 +63,5 @@
     }
     if (($prog =~ m/.pl$/i) && ($ENV{'GSDLOS'} =~ m/^windows/)) {
-	$prog ="\"$Config{perlpath}\" -S $prog";
+	$prog ="\"".&util::get_perl_exec()."\" -S $prog";
     }
  
Index: /main/trunk/greenstone2/perllib/lucenebuilder.pm
===================================================================
--- /main/trunk/greenstone2/perllib/lucenebuilder.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/lucenebuilder.pm	(revision 24362)
@@ -44,5 +44,5 @@
 use strict; 
 no strict 'refs';
-use Config; # for getting the perlpath in the recommended way
+use util;
 
 sub BEGIN {
@@ -82,5 +82,5 @@
     else
     {
-	$self->{'full_lucene_passes_exe'} = "\"$Config{perlpath}\" -S \"$lucene_passes_script\"";
+	$self->{'full_lucene_passes_exe'} = "\"".&util::get_perl_exec()."\" -S \"$lucene_passes_script\"";
     }
 
Index: /main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm	(revision 24362)
@@ -44,5 +44,5 @@
 no strict 'refs'; # allow filehandles to be variables and viceversa
 no strict 'subs';
-use Config; # for getting the perlpath in the recommended way
+use util;
 
 
@@ -279,5 +279,5 @@
 #    }
 
-    my $cmd = "\"$Config{perlpath}\" -S gsConvert.pl -verbose $verbosity ";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S gsConvert.pl -verbose $verbosity ";
     if (defined $self->{'convert_options'}) {
 	$cmd .= $self->{'convert_options'} . " ";
Index: /main/trunk/greenstone2/perllib/plugins/ConvertToRogPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/ConvertToRogPlugin.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/plugins/ConvertToRogPlugin.pm	(revision 24362)
@@ -31,5 +31,5 @@
 use strict;
 no strict 'refs'; # allow filehandles to be variables and viceversa
-use Config; # for getting the perlpath in the recommended way
+use util;
 
 sub BEGIN {
@@ -122,5 +122,5 @@
     # making sure the converter gives us the appropriate output type
     my $output_type = lc($convert_to);
-    my $cmd = "\"$Config{perlpath}\" -S gsMusicConvert.pl -verbose $verbosity -errlog \"$errlog\" -output $output_type \"$tmp_filename\"";
+    my $cmd = "\"".&util::get_perl_exec()."\" -S gsMusicConvert.pl -verbose $verbosity -errlog \"$errlog\" -output $output_type \"$tmp_filename\"";
     $output_type = `$cmd`;
 
Index: /main/trunk/greenstone2/perllib/util.pm
===================================================================
--- /main/trunk/greenstone2/perllib/util.pm	(revision 24361)
+++ /main/trunk/greenstone2/perllib/util.pm	(revision 24362)
@@ -31,4 +31,9 @@
 use File::Copy;
 use File::Basename;
+# Config for getting the perlpath in the recommended way, though it uses paths that are
+# hard-coded into the Config file that's generated upon configuring and compiling perl.
+# $^X works better in some cases to return the path to perl used to launch the script,
+# but if launched with plain "perl" (no full-path), that will be just what it returns.
+use Config; 
 
 # removes files (but not directories)
@@ -1604,3 +1609,28 @@
 }
 
+sub get_perl_exec() {	
+	my $perl_exec = $^X; # may return just "perl"
+	
+	if($ENV{'PERLPATH'}) {
+		# OR: # $perl_exec = &util::filename_cat($ENV{'PERLPATH'},"perl");
+		if($ENV{'GSDLOS'} =~ m/windows/) {
+			$perl_exec = "$ENV{'PERLPATH'}\\Perl.exe";
+		} else {
+			$perl_exec = "$ENV{'PERLPATH'}/perl";
+		}
+	} else { # no PERLPATH, use Config{perlpath} else $^X: special variables
+		# containing the full path to the current perl executable we're using
+		$perl_exec = $Config{perlpath}; # configured path for perl
+		if (!-e $perl_exec) { # may not point to location on this machine
+			$perl_exec = $^X; # may return just "perl"
+			if($perl_exec =~ m/^perl/i) { # warn if just perl or Perl.exe
+				print STDERR "**** WARNING: Perl exec found contains no path: $perl_exec";				
+			}
+		}
+    }
+	
+	return $perl_exec;
+}
+
+
 1;
