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

[perl #132923] RFE: enhancement of corelist script

Thread Next
From:
James E Keenan via RT
Date:
September 4, 2018 15:55
Subject:
[perl #132923] RFE: enhancement of corelist script
Message ID:
rt-4.0.24-28988-1536076516-1897.132923-15-0@perl.org
On Wed, 28 Feb 2018 22:27:41 GMT, LAWalsh wrote:
> 
> 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
> 

I think the maintainer of Module::CoreList should have first crack at evaluating this request.

However, I would recommend the following:

* Pull the patch against the version of Module::CoreList in Perl 5 blead, i.e., in a checkout from our git repository.

* Add tests for this feature in dist/Module-CoreList/t/.

* Attach the patch to this RT (or to your email response), i.e., don't inline the patch.

These steps will make the patch easier to evaluate.

Thank you very much.

-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=132923

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