Intrepid has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to mirror a hierarchy of Perl modules from CPAN: everything in ExtUtils:: but nothing else. Like a mini-cpan but not. Minicpan provides for exclusion of modules matching a regex but afaict provides no way to say "exclude everything except this".

Does anyone have knowledge of an existing script for something like this?
Thanks for your attention to this rather odd query.

Nov 08, 2024 at 20:55 UTC

Examine what is said, not who speaks.
Love the truth but pardon error.
Silence betokens consent.
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Mirroring CPAN by inclusion declaration rather than by exclusion

Replies are listed 'Best First'.
Re: Mirroring CPAN by inclusion declaration rather than by exclusion
by LanX (Saint) on Nov 08, 2024 at 21:18 UTC

      Rolf wrote:

      If you were referring to path_filters , please read the doc again, regex is only one of the possibilities, you can also provide a sub as filter. Should be straightforward...

      You got me, I indeed only skimmed the docs and then forgot about the option to use a sub. That's embarrassing but helpful.

      Edit

      My code is now doing what I want and in case someone is interested, here it is: (my code was NOT doing what I wanted; it was repeating packages for reasons I do not yet grasp. This code now fixes that.)

      EDIT

      second EDIT

      - messed up posting code by preprocessing it with Text::Textile. Obviously, this was unnecessary with Perlmonk's special processing of code blocks.

      #!/usr/bin/env perl # Last modified: Thu Nov 14 2024 06:16:33 PM -05:00 [EST] use strict; use v5.18; use utf8; use warnings; use CPAN::Mini; my %seen; CPAN::Mini->update_mirror( remote => "http://www.cpan.org", local => "/cygdrive/c/Users/somia/AppData/Roaming/minicpan", skip_perl => 1, log_level => 'info', dirmode => 0761, path_filters =>[ sub { exists $seen{$_[0]} and return 1; $seen{$_[0]} = 1; $_[0] =~ qr%/(ExtUtils-.+)% and do { print STDERR '-'x 76 , qq[\ +n], $1 , qq[\n]; return 0; } or return 1; } ], );
      Nov 30, 2024 at 19:51 UTC

      The open palm of desire
      Wants everything, it wants everything
      It wants soil as soft as summer
      And the strength to push like spring
      Paul Simon -> Further to Fly

Re: Mirroring CPAN by inclusion declaration rather than by exclusion
by InfiniteSilence (Curate) on Nov 10, 2024 at 06:26 UTC

    There's a list of all CPAN modules on Metacpan.org. I would get that and parse out (using HTML::Parser::Simple maybe?) the module names I was after and tuck them somewhere nice:

    cpan -g ExtUtils::CBuilder

    This gets the module and puts it in the current directory.

    Celebrate Intellectual Diversity

      That's a good suggestion, thanks. The one detail that makes a difference lies in whether you know all the modules you are interested in, in advance. Using my way creates a nice minimini-cpan of all ExtUtils:: even ones I did not know existed. I can now use perldoc and peruse them at my leisure.

      Nov 12, 2024 at 04:21 UTC
      Intrepid
        Is there a reason not to use the MetaCPAN website for this?
Re: Mirroring CPAN by inclusion declaration rather than by exclusion
by Anonymous Monk on Nov 08, 2024 at 21:19 UTC
    aka "include"