IPC::PrettyPipe::Arg - An argument to an IPC::PrettyPipe::Cmd command
version 0.13
use IPC::PrettyPipe::Arg; # standard constructor $arg = IPC::PrettyPipe::Arg->new( name => $name, value => $value, %attr ); # concise constructors $arg = IPC::PrettyPipe::Arg->new( $name ); $arg = IPC::PrettyPipe::Arg->new( [ $name, $value ] ); # perform value substitution $arg->valsubst( $pattern, $rep ); # return a rendered argument $arg->render;
IPC::PrettyPipe::Arg objects are containers for arguments to commands in an IPC::PrettyPipe::Cmd object.
# named parameters; may provide additional attributes $arg = IPC::PrettyPipe::Arg->new( \%attr ); # concise interface $arg = IPC::PrettyPipe::Arg->new( $name ); # switch arg $arg = IPC::PrettyPipe::Arg->new( [ $name, $value ] ); # arg w/ value
The available attributes are:
name
Required. The name of the argument.
value
The value of the argument. If an argument is a switch, no value is required.
pfx
A string prefix to be applied to the argument name before being rendered. This is often - or --.
-
--
A prefix is not required (the argument name may already have it). This attribute is useful when creating arguments from hashes where the keys do not contain a prefix.
sep
A string to insert between the argument name and value when rendering. In some cases arguments must be a single string where the name and value are separated with an = character; in other cases they are treated as separate entities. If sep is undef it indicates that they are treated as separate entities. It defaults to undef.
=
undef
$current_value = $self->pfx; $self->pfx( $new_value );
Get or set the value of the pfx attribute.
$current_value = $self->sep; $self->sep( $new_value );
Get or set the value of the sep attribute.
$name = $self->name;
The argument's name;
$name = $self->quoted_name;
The argument's name, appropriately quoted for passing as a single word to a Bourne compatible shell.
$value = $self->value;
The argument's value;
$value = $self->quoted_value;
The argument's value, appropriately quoted for passing as a single word to a Bourne compatible shell.
$bool = $self->has_value
Returns true if the argument has been assigned a value.
$bool = $self->has_blank_value
Returns true if the value is the empty string.
@rendered_arg = $arg->render;
Render the argument. If the argument's sep attribute is defined, render returns a string which looks like:
$pfx . $name . $sep . $value
If sep is not defined, it returns an array ref which looks like
$pfx . $name, $value
$bool = $arg->valmatch( $pattern );
Returns true if the argument has a value and it matches the passed regular expression.
$arg->valsubst( $pattern, $rep );
If the argument has a value, perform the equivalent to
$value =~ s/$pattern/$rep/;
Please report any bugs or feature requests to bug-ipc-prettypipe@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=IPC-PrettyPipe
Source is available at
https://gitlab.com/djerius/ipc-prettypipe
and may be cloned from
https://gitlab.com/djerius/ipc-prettypipe.git
Please see those modules/websites for more information related to this module.
IPC::PrettyPipe
Diab Jerius <djerius@cpan.org>
This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
To install IPC::PrettyPipe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IPC::PrettyPipe
CPAN shell
perl -MCPAN -e shell install IPC::PrettyPipe
For more information on module installation, please visit the detailed CPAN module installation guide.