| 1 | package FindApp::Utils::List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use FindApp::Utils::Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use FindApp::Utils::Assert qw( :all ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use FindApp::Utils::Syntax qw( function ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | sub alldir_map ( & ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | sub colonize ( @ ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | sub commify_and ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | sub commify_nor ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | sub commify_or ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | sub firsts_not_in_second ( \@ \@ ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | sub somedir_map ( &@ ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | sub subdir_map ( & ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub uniq ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub uniq_files ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | our $VERSION = v1.0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | our @EXPORT_OK = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | <commify_{and,or,nor}>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | alldir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | BLM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | colonize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | firsts_not_in_second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | somedir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | subdir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | uniq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | uniq_files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | all => \@EXPORT_OK, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 38 | ▶ | sub BLM() { return qw(bin lib man); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BLM: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub colonize(@) { join(":", @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colonize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 173 | ▶ | sub uniq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 173 | ▶ | my %seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq: not called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return grep { !$seen{$_}++ } grep {defined} @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ▶ | sub uniq_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq_files: called CC=5 SCAR=17.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | ▶ | my @input = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq_files: not called CC=5 SCAR=17.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 8 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | my @output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | for my $file (@input) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 40 | ▶ | next if $seen{$file}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 16 | ▶ | next unless stat $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 12 | my($dev,$ino) = stat _; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | next if $seen{$dev,$ino}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | push @output, $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | return @output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Yes, this isn't working right for undef. That shouldn't be a path element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # anyway but there are bugs in Env.pm this is working around. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 8 | ▶ | sub firsts_not_in_second(\@ \@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firsts_not_in_second: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | good_args(@_ == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firsts_not_in_second: not called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | my($aref, $bref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # worst case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my %seen = map { $_ => 1 } grep {defined} @$bref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return grep { ! $seen{$_} } grep {defined} @$aref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 32 | ▶ | sub somedir_map(&@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
somedir_map: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | good_args(@_ > 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return map { &$code } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 10 | ▶ | sub subdir_map(&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subdir_map: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | good_args(@_ == 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return somedir_map(\&$code, BLM); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 22 | ▶ | sub alldir_map(&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alldir_map: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | good_args(@_ == 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return somedir_map(\&$code, root => BLM); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | for my $CONJ (qw(and or nor)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | function "commify_$CONJ" => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=31.8
Subroutine
commify_nor: not called CC=5 SCAR=31.8
Subroutine
commify_or: not called CC=5 SCAR=31.8
Subroutine
commify_and: not called CC=5 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $comma = "@_" =~ /,/ ? ";" : ","; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | (@_ == 0) ? "" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | (@_ == 1) ? $_[0] : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | (@_ == 2) ? join(" $CONJ " => @_) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | join("$comma " => @_[0 .. ($#_-1)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | "$CONJ $_[-1]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | FindApp::Utils::List - FIXME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | use FindApp::Utils::List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | =head2 Exports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =item alldir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | =item BLM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | =item colonize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =item commify_and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | =item commify_nor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =item commify_or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | =item firsts_not_in_second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =item somedir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | =item subdir_map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =item uniq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | =item uniq_files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | =head1 ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =item L<FindApp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | =head1 CAVEATS AND PROVISOS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | =head1 HISTORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | Tom Christiansen << <tchrist@perl.com> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||