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 9, 2018 06:31
Subject:
Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX
Message ID:
CAEbNYu4+cNjcrpTgp_x=9oqh9pZ_ntFiYcNFaPVdzKP=eJdijA@mail.gmail.com
Added print statements in in the 'import' subroutine of
/scratch/gkallur/perl/lib/5.26.1/aix-thread-multi-64all/lib.pm
Here is the import subroutine with print statements

sub import {
    shift;

    my %names;
    print "**** Arguement passed : @_";
    foreach (reverse @_) {
        my $path = $_;          # we'll be modifying it, so break the alias
        if ($path eq '') {
            require Carp;
            Carp::carp("Empty compile time value given to use lib");
        }

        if ($path !~ /\.par$/i && -e $path && ! -d _) {
            require Carp;
            Carp::carp("Parameter to use lib must be directory, not file");
        }
        unshift(@INC, $path);
        print "**** After UNSHIFT in foreach loop : @INC";
        # Add any previous version directories we found at configure time
        foreach my $incver (@inc_version_list)
        {
            my $dir = "$path/$incver";
            unshift(@INC, $dir) if -d $dir;
        }
        # Put a corresponding archlib directory in front of $path if it
        # looks like $path has an archlib directory below it.
        my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
            = _get_dirs($path);
        unshift(@INC, $arch_dir)         if -d $arch_auto_dir;
        unshift(@INC, $version_dir)      if -d $version_dir;
        unshift(@INC, $version_arch_dir) if -d $version_arch_dir;
    }
    print "**** After foreach loop : @INC";

    # remove trailing duplicates
    @INC = grep { ++$names{$_} == 1 } @INC;
    print "**** Before return statement : @INC";
    return;
}

And the output is

-bash-4.2$  perl -le'use lib "/foo/bar"; print for @INC'
**** Arguement passed : /foo/bar
**** After foreach loop :
/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
**** Before return statement :
/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
/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

I found that it is not printing the print statement inside the foreach loop
( print "**** After UNSHIFT in foreach loop : @INC"; )

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