| 1 | #!perl | ||||||||||||
| 2 | |||||||||||||
| 3 | 29 | ▶ | use 5.010001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 29 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 29 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 29 | ▶ | use App::nauniq; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 29 | ▶ | use Getopt::Long; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 29 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||
| 11 | 29 | our $DATE = '2025-09-24'; # DATE | |||||||||||
| 12 | 29 | our $DIST = 'App-nauniq'; # DIST | |||||||||||
| 13 | 29 | our $VERSION = '0.112'; # VERSION | |||||||||||
| 14 | |||||||||||||
| 15 | 29 | my %Opts = ( | |||||||||||
| 16 | append => 0, | ||||||||||||
| 17 | check_chars => -1, | ||||||||||||
| 18 | forget_pattern => undef, | ||||||||||||
| 19 | ignore_case => 0, | ||||||||||||
| 20 | md5 => 0, | ||||||||||||
| 21 | num_entries => -1, | ||||||||||||
| 22 | read_output => 0, | ||||||||||||
| 23 | show_unique => 1, | ||||||||||||
| 24 | show_repeated => 0, | ||||||||||||
| 25 | skip_chars => 0, | ||||||||||||
| 26 | ); | ||||||||||||
| 27 | |||||||||||||
| 28 | 29 | ▶ | sub parse_cmdline { | ||||||||||
|
Subroutine
parse_cmdline: called CC=2 SCAR=7.4
| |||||||||||||
| 29 | 29 | Getopt::Long::Configure("gnu_getopt", "no_ignore_case"); | |||||||||||
| 30 | my $res = GetOptions( | ||||||||||||
| 31 | 'repeated|d' => | ||||||||||||
| 32 | 6 | ▶ | sub { $Opts{show_unique} = 0; $Opts{show_repeated} = 1 }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | 'ignore-case|i' => \$Opts{ignore_case}, | ||||||||||||
| 34 | 'num-entries=i' => \$Opts{num_entries}, | ||||||||||||
| 35 | 'skip-chars|s=i' => \$Opts{skip_chars}, | ||||||||||||
| 36 | 'unique|u' => | ||||||||||||
| 37 | 6 | ▶ | sub { $Opts{show_unique} = 1; $Opts{show_repeated} = 0 }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 38 | 'check-chars|w=i' => \$Opts{check_chars}, | ||||||||||||
| 39 | 1 | ▶ | 'a' => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | 1 | $Opts{append} = 1; $Opts{read_output} = 1; | |||||||||||
| 41 | }, | ||||||||||||
| 42 | 'append' => \$Opts{append}, | ||||||||||||
| 43 | 2 | ▶ | 'forget-pattern=s' => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||
| 44 | 2 | my ($cbobj, $val) = @_; | |||||||||||
| 45 | 2 | ▶ | eval { $val = $Opts{ignore_case} ? qr/$val/i : qr/$val/ }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | 2 | ▶ | if ($@) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | 1 | warn "Invalid regex pattern in --forget-pattern: $@\n"; exit 99; | |||||||||||
| 48 | } | ||||||||||||
| 49 | 1 | $Opts{forget_pattern} = $val; | |||||||||||
| 50 | }, | ||||||||||||
| 51 | 'md5' => \$Opts{md5}, | ||||||||||||
| 52 | 'read-output' => \$Opts{read_output}, | ||||||||||||
| 53 | 0 | ▶ | 'help|h' => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 54 | 0 | print <<USAGE; | |||||||||||
| 55 | Usage: | ||||||||||||
| 56 | nauniq [OPTIONS]... [INPUT [OUTPUT]] | ||||||||||||
| 57 | nauniq --help | ||||||||||||
| 58 | Options: | ||||||||||||
| 59 | --repeated, -d | ||||||||||||
| 60 | --ignore-case, -i | ||||||||||||
| 61 | --num-entries=N, -n | ||||||||||||
| 62 | --skip-chars=N, -s | ||||||||||||
| 63 | --unique, -u | ||||||||||||
| 64 | --check-chars=N, -w | ||||||||||||
| 65 | --append | ||||||||||||
| 66 | --read-output | ||||||||||||
| 67 | -a | ||||||||||||
| 68 | --md5 | ||||||||||||
| 69 | --forget-pattern=S | ||||||||||||
| 70 | For more details, see the manpage/documentation. | ||||||||||||
| 71 | USAGE | ||||||||||||
| 72 | 0 | exit 0; | |||||||||||
| 73 | }, | ||||||||||||
| 74 | 0 | ▶ | 'version|v' => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 75 | 0 | ▶ | print "nauniq version ", ($main::VERSION // 'dev'), "\n"; | ||||||||||
|
Condition0%0/2
$main::VERSION // "dev"
MC/DC0%0/1
$main::VERSION // "dev"
$main::VERSION
Truth table0%0/2
A
A= $main::VERSION
| |||||||||||||
| 76 | 0 | exit 0; | |||||||||||
| 77 | }, | ||||||||||||
| 78 | 29 | ); | |||||||||||
| 79 | 28 | ▶ | exit 99 if !$res; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | # MAIN | ||||||||||||
| 83 | |||||||||||||
| 84 | 29 | parse_cmdline(); | |||||||||||
| 85 | 28 | App::nauniq::run(%Opts); | |||||||||||
| 86 | |||||||||||||
| 87 | 1; | ||||||||||||
| 88 | # ABSTRACT: Non-adjacent uniq | ||||||||||||
| 89 | # PODNAME: nauniq | ||||||||||||
| 90 | |||||||||||||
| 91 | __END__ | ||||||||||||