App-eachperl

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

         * Quiet the :experimental(init_expr) warning of new Object::Pad

0.05    2022-02-28
        [CHANGES]
         * Added `--only-if` option
         * Fix oneline output format for things like `modversion` command
         * Updated for Object::Pad 0.54

0.04    2021-09-11
        [CHANGES]
         * Have `eachperl list` show which perls are thready
         * Rewrite to use Object::Pad
         * Better status printing during `exec`-like commands by using
           IO::Term::Status and running perls via PTY

0.03    2021-04-28
        [CHANGES]
         * Added `--reverse/-r` and `--stop-on-fail/-s` options

        [BUGFIXES]
         * Don't run `make` via $^X

bin/eachperl  view on Meta::CPAN


=head2 --only-if EXPR

An additional perl expression that will be evaluated within the target perl
which must additionally return true, to select that perl version. If it
returns false then this version will be skipped.

The L<Config> module will already be loaded here; this is useful for
expressions like

   --only-if '$Config{usethreads}'

=head2 --reverse, -r

Reverses the order in which perl versions are invoked.

=head2 --stop-on-fail, -s

Stops running after the first failure. Without this option, every version is
attempted even if some fail.

lib/App/eachperl.pm  view on Meta::CPAN

field $_only_if;
field $_reverse;
field $_stop_on_fail;

field $_io_term = IO::Term::Status->new_for_stdout;

class App::eachperl::_Perl {
   field $name         :param :reader  :Checked(Str);
   field $fullpath     :param :reader  :Checked(Str);
   field $version      :param :reader  :Checked($VersionString);
   field $is_threads   :param :reader;
   field $is_debugging :param :reader;
   field $is_devel     :param :reader;
   field $selected            :mutator;
}

field @_perlobjs;

ADJUST
{
   $_finder = Commandable::Finder::MethodAttributes->new( object => $self );

lib/App/eachperl.pm  view on Meta::CPAN

      # E.g. --until 5.14 means until the /end/ of the 5.14 series; so 5.14.999
      $_ .= ".999" if \$_ == \$_until_version and $_ !~ m/\.\d+\./;
      $_ = version->parse( $_ )->stringify;
   }

   if( my $perlnames = $_perls ) {
      foreach my $perl ( split m/\s+/, $perlnames ) {
         chomp( my $fullpath = `which $perl` );
         $? and warn( "Can't find perl at $perl" ), next;

         my ( $ver, $usethreads, $ccflags ) = split m/\n/,
            scalar `$fullpath -MConfig -e 'print "\$]\\n\$Config{usethreads}\\n\$Config{ccflags}\\n"'`;

         $ver = version->parse( $ver )->normal;
         my $threads = ( $usethreads eq "define" );
         my $debug = $ccflags =~ m/-DDEBUGGING\b/;
         my $devel = ( $ver =~ m/^v\d+\.(\d+)/ )[0] % 2;

         push @_perlobjs, App::eachperl::_Perl->new(
            name         => $perl,
            fullpath     => $fullpath,
            version      => $ver,
            is_threads   => $threads,
            is_debugging => $debug,
            is_devel     => $devel,
         );
      }
   }
}

method perls ()
{
   my @perls = @_perlobjs;

lib/App/eachperl.pm  view on Meta::CPAN

   return $_finder->find_and_invoke( $cinv );
}

method command_list
   :Command_description("List the available perls")
   ()
{
   foreach my $perl ( $self->perls ) {
      my @flags;
      push @flags, $perl->version;
      push @flags, "threads"   if $perl->is_threads;
      push @flags, "DEBUGGING" if $perl->is_debugging;
      push @flags, "devel"     if $perl->is_devel;

      printf "%s%s: %s (%s)\n",
         ( $perl->selected ? "* " : "  " ),
         $perl->name, $perl->fullpath, join( ",", @flags ),
      ;
   }
   return 0;
}



( run in 0.564 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )