String::Interpolate::Shell - Variable interpolation, shell style
version 0.02
use String::Interpolate::Shell qw[ strinterp ]; $interpolated_text = strinterp( $text, \%var, \%attr );
String::Interpolate::Shell interpolates variables into strings. Variables are specified using a syntax similar to that use by bash. Undefined variables can be silently ignored, removed from the string, can cause warnings to be issued or errors to be thrown.
Insert the value of the variable.
Insert the value of the variable. If it is not defined, the routine croaks with the specified message.
Insert the value of the variable. If it is not defined, process the specified default text for any variable interpolations and insert the result.
If the variable is defined, insert the result of interpolating any variables into the default text.
Insert the value of the variable. If it is not defined, insert the result of interpolating any variables into the default text and set the variable to the same value.
Insert the value of the variable as formatted according to the specified sprintf compatible format.
Insert the modified value of the variable. The modification is specified by op, which may be any of s, tr, or y, corresponding to the Perl operators of the same name. Delimiters for the modification may be any of those recognized by Perl. The modification is performed using a Perl string eval.
s
tr
y
In any of the bracketed forms, if the variable name is preceded with an exclamation mark (!) the name of the variable to be interpreted is taken from the value of the specified variable.
!
$interpolated_text = strinterp( $template, \%var, \%attr );
Return a string containing a copy of $template with variables interpolated.
$template
%var contains the variable names and values.
%var
%attr may contain the following entries:
%attr
This indicates how undefined variables should be interpolated
ignore
Ignore them. The token in $text is left as is.
$text
remove
Remove the token from $text.
This indicates how undefined variables should be reported.
silent
No message is returned.
warn
A message is output via carp().
carp()
fatal
A message is output via croak().
croak()
You can make new bug reports, and view existing ones, through the web interface at https://rt.cpan.org/Public/Dist/Display.html?Name=String-Interpolate-Shell.
Diab Jerius <djerius@cpan.org>
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
To install String::Interpolate::Shell, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Interpolate::Shell
CPAN shell
perl -MCPAN -e shell install String::Interpolate::Shell
For more information on module installation, please visit the detailed CPAN module installation guide.