/usr/share/perl5/App/ClusterSSH/Range.pm is in clusterssh 4.08-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | use strict;
use warnings;
package App::ClusterSSH::Range;
# ABSTRACT: Expand ranges such as {0..1} as well as other bsd_glob specs
=pod
=head1 NAME
ClusterSSH::Range - Object representing expandable ranges
=head1 SYNOPSIS
use App::ClusterSSH::Range;
my $range=App::ClusterSSH::Range->new();
my @list = $range->expand('range{0..5}');
=head1 DESCRIPTION
Perform string expansion looking for ranges before then finishing off
using C<File::Glob::bsd_glob>.
=cut
use File::Glob;
=head1 METHODS
=over 4
=item $range = App::ClusterSSH::Range->new();
Create a new object to perform range processing
=cut
sub new {
my ( $class, %args ) = @_;
my $self = {%args};
return bless $self, $class;
}
=item @expanded = $range->expand(@strings);
Expand the given strings. Ranges are checked for and processed. The
resulting string is then put through File::Glob::bsd_glob before being returned.
Ranges are of the form:
base{start..stop}
a{0..3} => a0 a1 a2 a3
b{4..6,9,12..14} => b4 b5 b6 b9 b12 b13 b14
=back
=cut
sub expand {
my ( $self, @items ) = @_;
my $range_regexp = qr/^\w+\{[\w\.,]+\}$/;
my @newlist;
foreach my $item (@items) {
if ( $item !~ m/$range_regexp/ ) {
push( @newlist, $item );
next;
}
my ( $base, $spec ) = $item =~ m/^(.*)?\{(.*)\}$/;
for my $section ( split( /,/, $spec ) ) {
my ( $start, $end );
if ( $section =~ m/\.\./ ) {
( $start, $end ) = split( /\.\./, $section, 2 );
}
$start = $section if ( !defined($start) );
$end = $start if ( !defined($end) );
foreach my $number ( $start .. $end ) {
push( @newlist, "$base$number" );
}
}
}
my @text = map { File::Glob::bsd_glob($_) } @newlist;
return wantarray ? @text : "@text";
}
1;
|