Created
April 21, 2014 19:35
-
-
Save wytten/11153842 to your computer and use it in GitHub Desktop.
Perl Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| printjson(db.GroovyScriptResult.findOne({name : "[%script%]", version : "[%version%]", database : "[%database%]", stackTrace:null})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Template; | |
| # some useful options (see below for full list) | |
| my $config = { | |
| # INCLUDE_PATH => '/search/path', # or list ref | |
| # INTERPOLATE => 1, # expand "$var" in plain text | |
| # POST_CHOMP => 1, # cleanup whitespace | |
| # PRE_PROCESS => 'header', # prefix each template | |
| # EVAL_PERL => 1, # evaluate Perl code blocks | |
| }; | |
| # create Template object | |
| my $template = Template->new($config); | |
| # define template variables for replacement | |
| my $vars = { | |
| version => $ARGV[0], | |
| database => $ARGV[1], | |
| script => $ARGV[2], | |
| }; | |
| # specify input filename, or file handle, text reference, etc. | |
| my $input = 'Query-template.js'; | |
| # process input template, substituting variables | |
| $template->process($input, $vars) | |
| || die $template->error(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment