App-PTP

 view release on metacpan or  search on metacpan

lib/App/PTP/Args.pm  view on Meta::CPAN

    '<>' => sub { push @inputs, $_[0] },  # Any options not matched otherwise.
    '' => sub { push @inputs, \$App::PTP::Files::stdin_marker },  # a single '-'
  )
}

sub is_int {
  my ($str) = @_;
  return looks_like_number($str) && int($str) == $str;
}

sub validate_cut_spec {
  my ($spec) = @_;
  my @fields = split /\s*,\s*/, $spec;
  for my $f (@fields) {
    die "Fields passed to --cut must all be integers: $f\n" unless is_int($f);
    $f-- if $f > 0;
  }
  return \@fields;
}

# The array associated with each action contains the name of the action, the

lib/App/PTP/Args.pm  view on Meta::CPAN

    },
    'insert-at-offset=s{2}' => sub {
      push @{$cur_pipeline}, ['insert-at-offset', \&do_insert_marked, {%modes}, $_[1]];
    },
    'clear-markers' =>
        sub { push @{$cur_pipeline}, ['clear-markers', \&do_set_markers, {%modes}, 0] },
    'set-all-markers' => sub {
      push @{$cur_pipeline}, ['set-all-markers', \&do_set_markers, {%modes}, 1];
    },
    'cut=s' => sub {
      push @{$cur_pipeline}, ['cut', \&do_cut, {%modes}, validate_cut_spec($_[1])];
    },
    'paste=s' => sub { push @{$cur_pipeline}, ['paste', \&do_paste, {%modes}, $_[1]] },
    'pivot' => sub { push @{$cur_pipeline}, ['pivot', \&do_pivot, {%modes}, 'pivot'] },
    'anti-pivot' => sub {
      push @{$cur_pipeline}, ['anti-pivot', \&do_pivot, {%modes}, 'anti-pivot'];
    },
    'transpose' => sub {
      push @{$cur_pipeline}, ['transpose', \&do_pivot, {%modes}, 'transpose'];
    },
    'number-lines|nl' =>

lib/App/PTP/Commands.pm  view on Meta::CPAN

# Applies the modal option on the given regex.
# This function is not exported.
sub prepare_re {
  my ($re, $modes) = @_;
  $re = base_prepare_re($re, $modes);
  my $r;
  if ($modes->{regex_engine} ne 'perl') {
    # Some play to correctly escape whatever special characters might be in the
    # regex while preserving its semantics. This relies on the fact that the
    # 'Terse' option of Data::Dumper is set in the main program.
    # The regex-engine variable has been validated in the Args module.
    my $str_re = Dumper($re);
    my $engine = 're::engine::'.$modes->{regex_engine};
    # We could the safe to avoid this perlcritic warning but we are not actually
    # executing code here, so the safe is not needed (and we would need to find
    # variable names that are guaranteed not to collide with user code).
    $r = eval "use ${engine}; \$re = $str_re; qr/\$re/s";  ## no critic (ProhibitStringyEval)
    if ($@) {
      chomp($@);
      die "FATAL: Cannot use the specified regex engine: ${@}\n";
    }

t/001-cpanfile.t  view on Meta::CPAN

  if ($ENV{HARNESS_ACTIVE} && !$ENV{EXTENDED_TESTING}) {
    skip_all('Extended test. Run manually or set $ENV{EXTENDED_TESTING} to a true value to run.');
  }
}

BEGIN {
  # This module seems to have trouble installing on some platform, so it’s
  # optional in the cpanfile and we skip the test if it’s not installed.
  eval 'use CPAN::Common::Index::Mux::Ordered';  ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval)
  if ($EVAL_ERROR) {
    skip_all('CPAN::Common::Index::Mux::Ordered required to validate the CPAN file');
  }
}

cpanfile_has_all_used_modules(
  perl_version => 5.024,
  develop => 1,
  suggests => 1,
  index => CPAN::Common::Index::Mux::Ordered->assemble(
    MetaDB => {},
    Mirror => {},



( run in 0.559 second using v1.01-cache-2.11-cpan-a5abf4f5562 )