in reply to Doing a "Print" to a predetermined location in another file

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 :)

Replies are listed 'Best First'.
Re: Re: Doing a "Print" to a predetermined location in another file
by Donnie (Acolyte) on Oct 12, 2002 at 17:33 UTC
    Dear Valerio, WOW! Thanks so much for the code example! I will be with this most of today! It is awesome people take so much time here to help one another. May the sun always shine upon you! Best Regards and many thanks!