develooper Front page | perl.perl5.porters | Postings from October 2018

Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX

Thread Previous | Thread Next
From:
Gururaj Kallur
Date:
October 5, 2018 20:37
Subject:
Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX
Message ID:
CAEbNYu5mpttjXDnYVh_MhH_rtp+tV=6AXS5zx9rHkO8+NCCuxA@mail.gmail.com
Here <DIRPATH> means absolute path of the module


I tried your small exercise as below

placed 133558-use-lib.pl in /scratch/gkallur
and replaced the line use 5.26.0 wth use 5.26.1 as we are using perl 5.26.1
in 133558-use-lib.pl
-bash-4.2$ cat 133558-use-lib.pl
#!/usr/bin/env perl
use 5.26.1;
use warnings;

use lib ('<DIRPATH>', $ENV{DIRPATH});
say "\@INC:";
say "  $_" for sort @INC;

say "";

use Hello;
Hello::hello();

say "";

use Goodbye;
Goodbye::goodbye();

-bash-4.2$ mkdir /scratch/gkallur/system_dirpath
-bash-4.2$ export DIRPATH=/scratch/gkallur/system_dirpath
-bash-4.2$ echo $DIRPATH
-bash-4.2$ /scratch/gkallur/system_dirpath


placed Hello.pm and Goodbye.pm in /scratch/gkallur/system_dirpath


which perl
/scratch/gkallur/perl/bin/perl

-bash-4.2$ perl -v

This is perl 5, version 26, subversion 1 (v5.26.1) built for
aix-thread-multi-64all

Copyright 1987-2017, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


-bash-4.2$ perl 133558-use-lib.pl
Can't locate Hello.pm in @INC (you may need to install the Hello module)
(@INC contains: /scratch/gkallur/perl/lib/5.26.1/aix-thread-multi-64all
/scratch/gkallur/perl/lib/5.26.1 /scratch/gkallur/perl/lib
../lib/site_perl/5.26.1/aix-thread-multi-64all ../lib/site_perl/5.26.1
../lib/5.26.1/aix-thread-multi-64all ../lib/5.26.1) at 133558-use-lib.pl
line 11.
BEGIN failed--compilation aborted at 133558-use-lib.pl line 11.


Same thing is working in Linux. And also working with perl 5.22.0 on IBM AIX

Here is the output of 133558-use-lib.pl with perl 5.22.0 on the same AIX
machine( replaced the line use 5.26.1 wth use 5.22.0 in 133558-use-lib.pl )

-bash-4.2$ pwd
/scratch/gkallur
-bash-4.2$ export PATH=/scratch/gkallur/perl522/bin:$PATH
-bash-4.2$ which perl
/scratch/gkallur/perl522/bin/perl
-bash-4.2$ perl -v

This is perl 5, version 22, subversion 0 (v5.22.0) built for
aix-thread-multi-64all

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

-bash-4.2$ perl 133558-use-lib.pl
@INC:
  .
  ../lib/5.22.0
  ../lib/5.22.0/aix-thread-multi-64all
  ../lib/site_perl/5.22.0
  ../lib/site_perl/5.22.0/aix-thread-multi-64all
  /scratch/gkallur/perl522/lib
  /scratch/gkallur/perl522/lib/5.22.0
  /scratch/gkallur/perl522/lib/5.22.0/aix-thread-multi-64all
  /scratch/gkallur/system_dirpath
  <DIRPATH>

Hello world

Goodbye world







On Fri, Oct 5, 2018 at 8:38 AM James E Keenan via RT <
perlbug-followup@perl.org> wrote:

> On Thu, 04 Oct 2018 11:28:40 GMT, gskallur@gmail.com wrote:
> >  perl 5.26  use lib pragma is not working in IBM AIX
> >
> > use lib "<DIRPATH>";
> >
> > Above code snippet fails to append the  DIRPATH to perl INC.
> > Because of which perl is not able to load modules in aix
>
> I have never used AIX, but unless something is *very* different there I do
> not think you are correct.
>
> The syntax 'use lib "<DIRPATH>";' only makes sense to me if you have a
> directory whose name is, literally, '<DIRPATH>' beneath the current working
> directory.  But if you have such a directory, and if it contains a Perl
> module, and if your Perl program is written correctly, then the module
> found in that directory can be use-d and its subroutines invoked.
>
> I suspect, however, that what the string '<DIRPATH>' means to you is a
> system-wide environmental variable holding a value for a special
> directory.  A properly written Perl program can handle that as well.
> Consider:
>
> #####
> $> cd /tmp
> $> mkdir '<DIRPATH>' # quotes needed because '<' is a shell metacharacter
> $> mkdir system_dirpath
> $> export DIRPATH=system_dirpath
> $> echo $DIRPATH
> system_dirpath
> #####
>
> Now, place attachment Hello.pm in directory '<DIRPATH>'.  Place attachment
> Goodbye.pm in directory system_dirpath.  Place program in
> 133558-use-lib.pl the current directory and run.
>
> #####
> $ perl 133558-use-lib.pl
> @INC:
>   /home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0
>   /home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/x86_64-linux
>   /home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0
>
> /home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0/x86_64-linux
>   /tmp/system_dirpath
>   <DIRPATH>
>
> Hello world
>
> Goodbye world
> #####
>
> Thank you very much.
> --
> James E Keenan (jkeenan@cpan.org)
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About