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 07:20
Subject:
Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX
Message ID:
CAEbNYu4SMu0jK9RK9ZUR-pt5nCHP5xMXdi-Gw_WuWyVWqAcKMg@mail.gmail.com
 Modified the import subroutine as below and is working fine. ( defined an
array my @sd=reverse @_; and used in foreach )
sub import {
    shift;

    my %names;
    print "**** Arguement passed : @_";
    my @sd=reverse @_;
    foreach (@sd) {
        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;
}

If reverse is inside the foreach then it is not working.

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