
=head1

Expects that $ARGV[0] is name of real perl script to execute, relative to the
$^X

The job of this script is mainly setting up %INC and $ENV{PERLLIB}

=cut

my $interpdir = $^X;

{
    $interpdir =~ s,/[^/]+$,,g;
    $interpdir =~ s,\\[^\\]+$,,g;
    $interpdir .= '/lib/';
    $ENV{PERLLIB} = $ENV{PERLLIB} ? "$ENV{PERLLIB}:$interpdir" : $interpdir;
    push @INC, $interpdir;
}

if (!@ARGV)
{
    print "usage: $0 <name-of-script-to-exec> [script-arguments]\n";
    exit 1;
}
{
    my $script = shift @ARGV;
    if (!-f $script) {
	print "error: can not open $script for reading: $!\n";
	exit 2;
    }
    do "$script";
    print "there were problems executing $script: $@\n" if $@;
}


