Front page | perl.perl5.porters |
Postings from February 2018
[perl #132923] RFE: enhancement of corelist script
From:
Linda Walsh
Date:
February 28, 2018 22:27
Subject:
[perl #132923] RFE: enhancement of corelist script
Message ID:
rt-4.0.24-5507-1519856861-382.132923-75-0@perl.org
# New Ticket Created by Linda Walsh
# Please include the string: [perl #132923]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=132923 >
This is a bug report for perl from perl-diddler@tlinx.org,
generated with the help of perlbug 1.40 running under perl 5.26.0.
-----------------------------------------------------------------
[Please describe your issue here]
I would like to propose an enhancement for the 'corelist'
command that comes with the CORE module 'Modules::CoreList'
Proposal is to add switch(es) '-t|--test' that would
act like '-v $] <MODNAME>' with the difference that
instead of telling you what version of the module is
in the given version of perl ($]=current), it returns
status via the script exit value: 0 if present, 1 if not.
This gives an easy way to test if a module is present in
CORE vs. need to be fetched from CPAN.
I threw together a sample patch against 5.26.0
for the 'corelist' program for my own use, and thought
it would be a good feature addition for the module in
CORE.
=====================
--- corelist.orig 2017-09-26 10:05:01.000000000 -0700
+++ corelist 2018-02-28 13:38:09.750160500 -0800
@@ -14,6 +14,7 @@
=head1 SYNOPSIS
corelist -v
+ corelist -t [ <ModuleName ]
corelist [-a|-d] <ModuleName> | /<ModuleRegex>/ [<ModuleVersion>] ...
corelist [-v <PerlVersion>] [ <ModuleName> | /<ModuleRegex>/ ] ...
corelist [-r <PerlVersion>] ...
@@ -145,7 +146,8 @@
GetOptions(
\%Opts,
- qw[ help|?! man! r|release:s v|version:s a! d diff|D feature|f u|upstream ]
+ qw[ help|?! man! r|release:s v|version:s a! d diff|D feature|f u|upstream
+ t|test a!]
);
pod2usage(1) if $Opts{help};
@@ -175,6 +177,8 @@
exit 0;
}
+$Opts{v}=$] if exists($Opts{t}) ? 1 : 0;
+
if(exists $Opts{v} ){
if( !$Opts{v} ) {
print "\nModule::CoreList has info on the following perl versions:\n";
@@ -278,6 +282,8 @@
pod2usage(0);
}
+my $exit_status=0;
+
while (@ARGV) {
my ($mod, $ver);
if ($ARGV[0] =~ /=/) {
@@ -288,7 +294,7 @@
}
if ($mod !~ m|^/(.*)/([imosx]*)$|) { # not a regex
- module_version($mod,$ver);
+ ++$exit_status if module_version($mod,$ver);
} else {
my $re;
eval { $re = $2 ? qr/(?$2)($1)/ : qr/$1/; }; # trap exceptions while building regex
@@ -310,7 +316,7 @@
}
}
-exit();
+exit($exit_status);
sub module_version {
my($mod,$ver) = @_;
@@ -319,8 +325,9 @@
my $numeric_v = numify_version($Opts{v});
my $version_hash = Module::CoreList->find_version($numeric_v);
if ($version_hash) {
+ return $version_hash->{$mod} ? 0 : 1 if $Opts{t};
print $mod, " ", $version_hash->{$mod} || 'undef', "\n";
- return;
+ return 0;
}
else { die "Shouldn't happen" }
}
=====================
The above is the simple case of checking for the module
in the running vesrion of perl
Thanks,
Linda Walsh
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=wishlist
---
Site configuration information for perl 5.26.0:
Configured by law at Sat Oct 7 15:42:15 PDT 2017.
Summary of my perl5 (revision 5 version 26 subversion 0) configuration:
Platform:
osname=linux
osvers=4.13.5-isht-van
archname=x86_64-linux-thread-multi-ld
uname='linux ishtar 4.13.5-isht-van #2 smp preempt thu oct 5 15:26:06 pdt 2017 x86_64 gnulinux '
config_args=''
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=define
usemymalloc=n
default_inc_excludes_dot=undef
bincompat5005=undef
Compiler:
cc='gcc'
ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-explicit -I/home/perl/perl-5.26.0/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
optimize='-O2'
cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-explicit -I/home/perl/perl-5.26.0/include'
ccversion=''
gccversion='7.1.0'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='long double'
nvsize=16
Off_t='off_t'
lseeksize=8
alignbytes=16
prototype=define
Linker and Libraries:
ld='gcc'
ldflags ='-fstack-protector-explicit -I/home/perl/perl-5.26.0/include'
libpth=/usr/local/lib //lib /usr/lib64/gcc/x86_64-pc-linux-gnu/7/include-fixed /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.19.so
so=so
useshrplib=true
libperl=libperl-5.26.0.so
gnulibc_version='2.19'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E -Wl,-rpath,/home/perl/perl-5.26.0/usr/lib/5.26.0/x86_64-linux-thread-multi-ld/CORE'
cccdlflags='-fPIC'
lddlflags='-shared -O2'
---
@INC for perl 5.26.0:
/home/law/bin/lib
/home/perl/perl-5.26.0/usr/lib/site_perl/5.26.0/x86_64-linux-thread-multi-ld
/home/perl/perl-5.26.0/usr/lib/site_perl/5.26.0
/home/perl/perl-5.26.0/usr/lib/5.26.0/x86_64-linux-thread-multi-ld
/home/perl/perl-5.26.0/usr/lib/5.26.0
---
Environment for perl 5.26.0:
HOME=/home/law
LANG (unset)
LANGUAGE (unset)
LC_COLLATE=C
LC_CTYPE=en_US.UTF-8
LC_MESSAGES=C
LC_MONETARY=C
LC_NUMERIC=C
LC_TIME=C
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/perl/perl-5.26.0:.:/sbin:/home/law/bin/lib:/home/law/bin:/usr/local/bin:/usr/bin:/bin:/opt/kde3/bin:/usr/sbin:/etc/local/func_lib:/home/law/lib
PERL5OPT=-Mutf8 -CSA -I/home/law/bin/lib
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #132923] RFE: enhancement of corelist script
by Linda Walsh