Hi Donnie,
you need a template system :) Something like
HTML::Template or Text::Template.
This my solution for your problem, a bit overkill and
maybe unorthodox. Suppose you have a file named script.in
with the following content:
#!/usr/bin/perl
my $hold='<TMPL_VAR HOLD>';
my $leave = '<TMPL_VAR LEAVE>';
my $munge = '<TMPL_VAR MUNGE>';
The program that will substitute HOLD, LEAVE and MUNGE is
something like this:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Template;
use vars qw( $in %args $template );
$in = shift @ARGV;
%args = @ARGV;
$template = HTML::Template->new( filename => $in );
$template->param(%args);
print $template->output;
Now you can use it this way:
./fill_blanks script.in HOLD this LEAVE that MUNGE these
which prints the following:
#!/usr/bin/perl
$hold = "this";
$leave = "that";
$munge = "these";
Ciao, Valerio
Update: you are welcome Donnie :) |