| 1 | # vim:set ft=perl ts=4 sw=4 et | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package SSH::Batch::ForNodes; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 64 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 64 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 64 | our $VERSION = '0.029'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 64 | ▶ | use Set::Scalar; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 64 | ▶ | use File::HomeDir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub clear_universe (); | ||||||||||||||||||||||||||||
| 14 | sub init_rc (); | ||||||||||||||||||||||||||||
| 15 | sub load_rc ($$); | ||||||||||||||||||||||||||||
| 16 | sub parse_line ($$); | ||||||||||||||||||||||||||||
| 17 | sub parse_expr ($); | ||||||||||||||||||||||||||||
| 18 | sub parse_term ($); | ||||||||||||||||||||||||||||
| 19 | sub parse_atom ($); | ||||||||||||||||||||||||||||
| 20 | sub expand_seg ($@); | ||||||||||||||||||||||||||||
| 21 | sub expand_wildcards ($); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 64 | my $RangePat = qr/\w+(?:(?:-|\.\.)\w+)?/; | |||||||||||||||||||||||||||
| 24 | 64 | my %Vars; | |||||||||||||||||||||||||||
| 25 | 64 | our $HostUniverse = Set::Scalar->new; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub clear_universe () { | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $HostUniverse->empty; | ||||||||||||||||||||||||||
|
Subroutine
clear_universe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub init_rc () { | ||||||||||||||||||||||||||||
| 32 | 52 | ▶ | my $rcfile = $ENV{SSH_BATCH_RC} || q(); | ||||||||||||||||||||||||||
|
Subroutine
init_rc: called CC=9 SCAR=25.6
Pod
undocumented
Condition50%1/2
$ENV{'SSH_BATCH_RC'} || ''
MC/DC0%0/1
$ENV{'SSH_BATCH_RC'} || ''
$ENV{'SSH_BATCH_RC'}
Truth table50%1/2
A
A= $ENV{'SSH_BATCH_RC'}
| |||||||||||||||||||||||||||||
| 33 | 52 | ▶ | if(! $rcfile){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 52 | ▶ | my $home = $ENV{SSH_BATCH_HOME} || File::HomeDir->my_home; | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'SSH_BATCH_HOME'} || 'File::HomeDir'->my_home
MC/DC0%0/2
$ENV{'SSH_BATCH_HOME'} || 'File::HomeDir'->my_home
$ENV{'SSH_BATCH_HOME'}
'File::HomeDir'->my_home
Truth table33%1/3
A || B
A= $ENV{'SSH_BATCH_HOME'}B= 'File::HomeDir'->my_home
| |||||||||||||||||||||||||||||
| 35 | 52 | ▶ | if (!defined $home || !-d $home) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $home and -d $home
MC/DC50%1/2
defined $home and -d $home
defined $home
-d $home
Truth table66%2/3
A and B
A= defined $homeB= -d $home
| |||||||||||||||||||||||||||||
| 36 | 3 | die "Can't find the home for the current user.\n"; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 49 | $rcfile = "$home/.fornodesrc"; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # auto create $rcfile if $rcfile not exists | ||||||||||||||||||||||||||||
| 42 | 49 | ▶ | if (! -e $rcfile) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | open my $rc, '>', $rcfile or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | die "Can't auto create $rcfile: $!\n"; | ||||||||||||||||||||||||||||
| 45 | 0 | close $rc; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 49 | ▶ | open my $rc, $rcfile or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | die "Can't open $rcfile for reading: $!\n"; | ||||||||||||||||||||||||||||
| 50 | 49 | load_rc($rc, $rcfile); | |||||||||||||||||||||||||||
| 51 | 49 | close $rc; | |||||||||||||||||||||||||||
| 52 | #return ($rc, $rcfile); | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub load_rc ($$) { | ||||||||||||||||||||||||||||
| 56 | 49 | ▶ | my ($rc, $rcfile) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_rc: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 49 | my $accum_ln; | |||||||||||||||||||||||||||
| 58 | 49 | ▶ | while (<$rc>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 92 | s/\#.*//; | |||||||||||||||||||||||||||
| 60 | 92 | ▶ | next if /^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 74 | chomp; | |||||||||||||||||||||||||||
| 62 | 74 | ▶ | if (s/\\\s*$//s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 5 | $accum_ln .= " $_"; | |||||||||||||||||||||||||||
| 64 | 5 | next; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 69 | ▶ | if (defined $accum_ln) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 3 | parse_line("$accum_ln $_", $rcfile); | |||||||||||||||||||||||||||
| 68 | 3 | undef $accum_ln; | |||||||||||||||||||||||||||
| 69 | 3 | next; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 66 | parse_line($_, $rcfile); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub parse_line ($$) { | ||||||||||||||||||||||||||||
| 76 | 69 | ▶ | local *_ = \($_[0]); | ||||||||||||||||||||||||||
|
Subroutine
parse_line: called CC=5 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 69 | my $rcfile = $_[1]; | |||||||||||||||||||||||||||
| 78 | 69 | ▶ | if (/^\s*([^=\s]*)\s*=\s*(.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 69 | my ($var, $def) = ($1, $2); | |||||||||||||||||||||||||||
| 80 | 69 | ▶ | if ($var !~ /^\w[-\.\w]*$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | die "Invalid variable name in $rcfile, line $.: ", | |||||||||||||||||||||||||||
| 82 | "$var\n"; | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 69 | my $set; | |||||||||||||||||||||||||||
| 85 | 69 | eval { | |||||||||||||||||||||||||||
| 86 | 69 | $set = parse_expr($def); | |||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||
| 88 | 69 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | die "Failed to parse the variable $var\'s value in $rcfile, ", | |||||||||||||||||||||||||||
| 90 | "line $.: $@"; | ||||||||||||||||||||||||||||
| 91 | } else { | ||||||||||||||||||||||||||||
| 92 | 69 | ▶ | if (defined $Vars{$var}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | die "Variable redefinition in $rcfile line $.: $_\n"; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 69 | $Vars{$var} = $set; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | } else { | ||||||||||||||||||||||||||||
| 98 | 0 | die "Syntax error in $rcfile, line $.: $_\n"; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub parse_expr ($) { | ||||||||||||||||||||||||||||
| 103 | 116 | ▶ | local *_ = \($_[0]); | ||||||||||||||||||||||||||
|
Subroutine
parse_expr: called CC=20 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # trim | ||||||||||||||||||||||||||||
| 106 | 116 | s/(?:^\s+|\s+$)//gs; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 116 | my @toplevel; | |||||||||||||||||||||||||||
| 109 | 116 | while (1) { | |||||||||||||||||||||||||||
| 110 | 374 | ▶ | if (/\G \s* (?<= [\}\)\s] ) ([-+*\/]) (?= [\{\(\s] ) \s*/gcx) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 111 | 33 | push @toplevel, $1; | |||||||||||||||||||||||||||
| 112 | } elsif (/\G \{ .*? \} /gcx) { | ||||||||||||||||||||||||||||
| 113 | 47 | push @toplevel, $&; | |||||||||||||||||||||||||||
| 114 | } elsif (/\G \S+ /gcx) { | ||||||||||||||||||||||||||||
| 115 | 140 | push @toplevel, $&; | |||||||||||||||||||||||||||
| 116 | } elsif (/\G \s+ /gcx) { | ||||||||||||||||||||||||||||
| 117 | 38 | push @toplevel, '+'; | |||||||||||||||||||||||||||
| 118 | } else { | ||||||||||||||||||||||||||||
| 119 | 116 | last; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 116 | my $expect_term = 1; | |||||||||||||||||||||||||||
| 123 | 116 | for my $raw_op (@toplevel) { # op would be either operands or operators | |||||||||||||||||||||||||||
| 124 | 258 | my $op = $raw_op; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 258 | ▶ | if ($op =~ /^[-+*\/]$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 71 | ▶ | if ($expect_term) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | die "Expecting terms but found operator $op.\n"; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | 71 | $expect_term = 1; | |||||||||||||||||||||||||||
| 131 | 71 | next; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | 187 | ▶ | if (!$expect_term) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | die "Expecting operators but found term $op\n"; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 187 | $expect_term = 0; | |||||||||||||||||||||||||||
| 137 | 187 | eval { | |||||||||||||||||||||||||||
| 138 | 187 | $raw_op = parse_term($op); | |||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||
| 140 | 187 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 4 | die $@; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 112 | my @lower; | |||||||||||||||||||||||||||
| 145 | 112 | ▶ | while (@toplevel > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 71 | my $a = shift @toplevel; | |||||||||||||||||||||||||||
| 147 | 71 | my $op = shift @toplevel; | |||||||||||||||||||||||||||
| 148 | 71 | ▶ | if ($op eq '+') { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 149 | 56 | push @lower, $a, $op; | |||||||||||||||||||||||||||
| 150 | #unshift @toplevel, $a + $b; | ||||||||||||||||||||||||||||
| 151 | } elsif ($op eq '-') { | ||||||||||||||||||||||||||||
| 152 | 8 | push @lower, $a, $op; | |||||||||||||||||||||||||||
| 153 | #unshift @toplevel, $a - $b; | ||||||||||||||||||||||||||||
| 154 | } elsif ($op eq '*') { | ||||||||||||||||||||||||||||
| 155 | 6 | my $b = shift @toplevel; | |||||||||||||||||||||||||||
| 156 | 6 | unshift @toplevel, $a * $b; | |||||||||||||||||||||||||||
| 157 | } elsif ($op eq '/') { | ||||||||||||||||||||||||||||
| 158 | 1 | my $b = shift @toplevel; | |||||||||||||||||||||||||||
| 159 | 1 | unshift @toplevel, $a / $b; | |||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||
| 161 | 0 | die "Invalid operator : [$op]\n"; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 112 | ▶ | if (@toplevel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 112 | push @lower, @toplevel; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | 112 | ▶ | while (@lower > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 64 | my $a = shift @lower; | |||||||||||||||||||||||||||
| 169 | 64 | my $op = shift @lower; | |||||||||||||||||||||||||||
| 170 | 64 | my $b = shift @lower; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 64 | ▶ | if ($op eq '+') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 173 | 56 | unshift @lower, $a + $b; | |||||||||||||||||||||||||||
| 174 | } elsif ($op eq '-') { | ||||||||||||||||||||||||||||
| 175 | 8 | unshift @lower, $a - $b; | |||||||||||||||||||||||||||
| 176 | } else { | ||||||||||||||||||||||||||||
| 177 | 0 | die "Unexpected operator: [$op]\n"; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 112 | ▶ | return @lower ? $lower[0] : Set::Scalar->new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub parse_term ($) { | ||||||||||||||||||||||||||||
| 184 | 187 | ▶ | local *_ = \($_[0]); | ||||||||||||||||||||||||||
|
Subroutine
parse_term: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 185 | 187 | ▶ | if (/^ \{ ( [^}\s]* ) \} $/x) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 46 | my $var = $1; | |||||||||||||||||||||||||||
| 187 | 46 | ▶ | if ($var !~ /^\w[-\.\w]*$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | die "Invalid variable name in term $_: $var\n"; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 46 | my $set = $Vars{$var}; | |||||||||||||||||||||||||||
| 191 | 46 | ▶ | if (!defined $set) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 0 | die "Variable $var not defined.\n"; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 46 | return $set; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | 141 | ▶ | if (/[{}]/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 1 | die "Invalid variable reference syntax: $_\n"; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 140 | return parse_atom($_); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | sub parse_atom ($) { | ||||||||||||||||||||||||||||
| 203 | 140 | ▶ | local *_ = \($_[0]); | ||||||||||||||||||||||||||
|
Subroutine
parse_atom: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 140 | my @segs; | |||||||||||||||||||||||||||
| 205 | 140 | while (1) { | |||||||||||||||||||||||||||
| 206 | 352 | ▶ | if (/ \G \[ ( [^\]]* ) \] /xgc) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 207 | 44 | my $range = $1; | |||||||||||||||||||||||||||
| 208 | #warn "Range: $range\n"; | ||||||||||||||||||||||||||||
| 209 | 44 | ▶ | if ($range !~ m/^$RangePat(?:\s*,\s*$RangePat)*$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 3 | die "Bad range: [$range]\n"; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 41 | my @ranges = split /,/, $range; | |||||||||||||||||||||||||||
| 213 | 41 | my @num; | |||||||||||||||||||||||||||
| 214 | 41 | for my $range (@ranges) { | |||||||||||||||||||||||||||
| 215 | 60 | my ($a, $b) = split /(?:-|\.\.)/, $range; | |||||||||||||||||||||||||||
| 216 | #if (defined $b && ($a =~ /\D/ || $b =~ /\D/) && length $a ne length $b) { | ||||||||||||||||||||||||||||
| 217 | #die "End points are not of equal lengths in the host range: $a-$b\n"; | ||||||||||||||||||||||||||||
| 218 | #} | ||||||||||||||||||||||||||||
| 219 | 60 | ▶ | push @num, defined $b ? $a..$b : $a; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | #print "@num"; | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | 41 | push @segs, \@num; | |||||||||||||||||||||||||||
| 223 | } elsif (/\G[^\[]+/gc) { | ||||||||||||||||||||||||||||
| 224 | 171 | push @segs, [$&]; | |||||||||||||||||||||||||||
| 225 | 171 | next; | |||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||
| 227 | 137 | last; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 137 | my $hosts = expand_seg(\@segs); | |||||||||||||||||||||||||||
| 231 | 137 | my $set = Set::Scalar->new; | |||||||||||||||||||||||||||
| 232 | 137 | for my $host (@$hosts) { | |||||||||||||||||||||||||||
| 233 | #warn "Host: $host\n"; | ||||||||||||||||||||||||||||
| 234 | 428 | ▶ | if ($host =~ /[\*\?]/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 17 | $set->insert(expand_wildcards($host)); | |||||||||||||||||||||||||||
| 236 | } else { | ||||||||||||||||||||||||||||
| 237 | #warn "Inserting $host: $host\n"; | ||||||||||||||||||||||||||||
| 238 | 411 | $set->insert($host); | |||||||||||||||||||||||||||
| 239 | 411 | $HostUniverse->insert($host); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 137 | return $set; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | sub expand_seg ($@) { | ||||||||||||||||||||||||||||
| 246 | 349 | ▶ | my ($list, $prefixes) = @_; | ||||||||||||||||||||||||||
|
Subroutine
expand_seg: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 247 | 349 | my $cur = shift @$list; | |||||||||||||||||||||||||||
| 248 | 349 | ▶ | return $prefixes unless defined $cur; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 212 | my @new_prefixes; | |||||||||||||||||||||||||||
| 250 | 212 | ▶ | if (!$prefixes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 137 | for my $alt (@$cur) { | |||||||||||||||||||||||||||
| 252 | 152 | push @new_prefixes, $alt; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | } else { | ||||||||||||||||||||||||||||
| 255 | 75 | for my $prefix (@$prefixes) { | |||||||||||||||||||||||||||
| 256 | 368 | for my $alt (@$cur) { | |||||||||||||||||||||||||||
| 257 | 644 | push @new_prefixes, $prefix . $alt; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 212 | return expand_seg($list, \@new_prefixes); | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | sub expand_wildcards ($) { | ||||||||||||||||||||||||||||
| 265 | 17 | ▶ | my $pat = quotemeta $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
expand_wildcards: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 266 | 17 | $pat =~ s/\\\*/.*?/g; | |||||||||||||||||||||||||||
| 267 | 17 | $pat =~ s/\\\?/./g; | |||||||||||||||||||||||||||
| 268 | 17 | my @retvals; | |||||||||||||||||||||||||||
| 269 | 17 | ▶ | while (defined(my $host = $HostUniverse->each)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 102 | ▶ | if ($host =~ /^$pat$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 16 | push @retvals, $host; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | 17 | return @retvals; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 64 | 1; | |||||||||||||||||||||||||||
| 278 | __END__ | ||||||||||||||||||||||||||||