App-Sets
view release on metacpan or search on metacpan
sets -- -first-set ^ -second-set
In general, anyway, the first non-option argument terminates the list
of options as well, so the example above would work also without the
C<-->. In the pathological case that your file is named C<-s>, anyway,
you would need the explicit termination of options with C<-->. You get
the idea.
Files with spaces and other weird stuff can be specified by means
of quotes or escapes. The following are all valid methods of subtracting
C<to remove> from C<input file>:
sets "'input file' - 'to remove'"
sets '"input file" - "to remove"'
sets 'input\ file - to\ remove'
sets "input\\ file - to\\ remove"
sets input\ file - to\ remove
The first two examples use single and double quoting. The third example
uses a backslash to escape the spaces, as well as the fourth example in
which the escape character is repeated due to the interpolation rules
of the shell. The last example leverages upon the shell rules for
escaping AND the fact that simple expressions like that can be specified
as multiple arguments instead of a single string.
=head1 OPTIONS
=over
=item --binmode | -b I<string>
lib/App/Sets.pm view on Meta::CPAN
my @args = populate_config(@_);
my $input;
if (@args > 1) {
shift @args if $args[0] eq '--';
LOGDIE "only file op file [op file...] "
. "with multiple parameters (@args)...\n"
unless @args % 2;
my @chunks;
while (@args) {
push @chunks, escape(shift @args);
push @chunks, shift @args if @args;
}
$input = join ' ', @chunks;
} ## end if (@args > 1)
else {
$input = shift @args;
}
LOGLEVEL('DEBUG') if $config{parsedebug};
DEBUG "parsing >$input<";
lib/App/Sets.pm view on Meta::CPAN
binmode STDOUT, $config{binmode};
my $it = expression($expression);
while (defined(my $item = $it->drop())) {
print {*STDOUT} $item;
print {*STDOUT} "\n" if $config{trim};
}
return;
} ## end sub run
sub escape {
my ($text) = @_;
$text =~ s{(\W)}{\\$1}gmxs;
return $text;
}
sub expression {
my ($expression) = @_;
if (ref $expression) { # operation
my ($op, $l, $r) = @$expression;
my $sub = App::Sets::Operations->can($op);
( run in 0.476 second using v1.01-cache-2.11-cpan-c21f80fb71c )