Ignore:
Timestamp:
2011-08-03T21:17:30+12:00 (13 years ago)
Author:
ak19
Message:

The method of locating perl has changed once more: util now defines the fuction get_perl_exec which is used by other scripts to obtain the path to the perl executable they should use.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r24291 r24362  
    3131use File::Copy;
    3232use File::Basename;
     33# Config for getting the perlpath in the recommended way, though it uses paths that are
     34# hard-coded into the Config file that's generated upon configuring and compiling perl.
     35# $^X works better in some cases to return the path to perl used to launch the script,
     36# but if launched with plain "perl" (no full-path), that will be just what it returns.
     37use Config;
    3338
    3439# removes files (but not directories)
     
    16041609}
    16051610
     1611sub get_perl_exec() {   
     1612    my $perl_exec = $^X; # may return just "perl"
     1613   
     1614    if($ENV{'PERLPATH'}) {
     1615        # OR: # $perl_exec = &util::filename_cat($ENV{'PERLPATH'},"perl");
     1616        if($ENV{'GSDLOS'} =~ m/windows/) {
     1617            $perl_exec = "$ENV{'PERLPATH'}\\Perl.exe";
     1618        } else {
     1619            $perl_exec = "$ENV{'PERLPATH'}/perl";
     1620        }
     1621    } else { # no PERLPATH, use Config{perlpath} else $^X: special variables
     1622        # containing the full path to the current perl executable we're using
     1623        $perl_exec = $Config{perlpath}; # configured path for perl
     1624        if (!-e $perl_exec) { # may not point to location on this machine
     1625            $perl_exec = $^X; # may return just "perl"
     1626            if($perl_exec =~ m/^perl/i) { # warn if just perl or Perl.exe
     1627                print STDERR "**** WARNING: Perl exec found contains no path: $perl_exec";             
     1628            }
     1629        }
     1630    }
     1631   
     1632    return $perl_exec;
     1633}
     1634
     1635
    160616361;
Note: See TracChangeset for help on using the changeset viewer.