Mj1234 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have a batch file as shown below.
pushd %Root% call perl Folder2\Perl1.pl

The batch file in turn calls the Perl1.pl file which contains the code as below

use strict; use warnings; use lib "Folder3\\Folder4\\"; use Param; my $Path = $Param::My_Path; print "$Path\n";

When I execute the the batch file I get the error "Can't locate Param.pm in @INC (@INC contains: Folder3\Folder4\". But I want this path to be relative to the path %Root% pushd in my batch file.

Is there a way these paths can look from the %Root% for all the relative paths?

Replies are listed 'Best First'.
Re: relative path is 'use lib' in perl
by choroba (Cardinal) on Apr 06, 2016 at 06:33 UTC
    Have you noticed the CAVEAT part in the documentation?

    > In order to keep lib.pm small and simple, it only works with Unix filepaths.

    use lib 'Folder3/Folder4';

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: relative path is 'use lib' in perl
by SimonPratt (Friar) on Apr 06, 2016 at 08:08 UTC

    This works for me in Windows, Perl v5.16.2: BEGIN { push @INC, '.\subdir\\'; }

    The single period defines the current working directory and everything is relative from there.

    EDIT: Sorry, forgot the above shuold be wrapped in a BEGIN block

Re: relative path is 'use lib' in perl
by beech (Parson) on Apr 06, 2016 at 06:37 UTC