App-SimpleScan
view release on metacpan or search on metacpan
bin/simple_scan view on Meta::CPAN
%%now "@{[scalar localtime]}"
The first example allows you to pass in a value from the environment
variable C<$LANGUAGE>; the second gets the current date and time as a string (so its
value would be something like "Tue Feb 14 14:21:56 2006").
Lastly, you can use backticked strings to denote a command to be
executed by the shell; the command's output will be used in place of
the quoted string.
As an example, if we have the script C<languages> which looks like this:
#!/bin/sh
echo "perl java python ruby"
and the substitution
%%language `languages`
then the values finally assigned to C<language> would be
C<perl java ruby python>.
lib/App/SimpleScan/Substitution.pm view on Meta::CPAN
# Clone the dictionary, because we're going to modify it with the
# fixed values. This effectively prunes the substitution tree at the
# points where we've already done substitutions.
my %dictionary = (%{ $self->dictionary() }, $line_obj->fixed);
# Localize the slot that contains the dictionary and replace it
# with our newly-constructed, possibly-pruned one.
local($self->{dictionary}) = \%dictionary;
# Find the most-deeply-nested substitutions; we need to do those first;
# prune out anything that looks like a variable, but isn't (because
# there's no value for it in the dictionary).
my @var_names = grep { defined $self->dictionary->{$_} }
$self->_deepest_substitution("$line_obj");
# We have none.
return $line_obj unless @var_names;
# What we want to do is to get every possible combination of the
# active variables in this line from the dictionary, and substitute
# all these into the line.
( run in 0.455 second using v1.01-cache-2.11-cpan-64827b87656 )