If I've reverse engineered a spec from your post correctly, then something along these lines should suffice:
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $infile = shift; open my $in, '<', $infile or die "Cannot open $infile: $!"; while (<$in>) { chomp; s/=\s*$/"= " . shift/e; say; } close $in;
Running it with your sample input gives:
$ ./bar.pl template.config list.txt file_list.txt ;; path to config file $;INPUT_FILE$; = list.txt ;; path to list of config files $;INPUT_FILE_LIST$; = file_list.txt ;; path to temporary directory $;TEMP_DIR$; = $;TMP_DIR$; ;; use --v for verbose summary $;OTHER_ARGS$; = --v
Update: removed a redundant mention of @ARGV in the substitution.
Update 2: for the avoidance of any confusion resulting from the parent post having been rewritten to change both the data set and the invocation, here's the original input file:
;; path to config file $;INPUT_FILE$; = ;; path to list of config files $;INPUT_FILE_LIST$; = ;; path to temporary directory $;TEMP_DIR$; = $;TMP_DIR$; ;; use --v for verbose summary $;OTHER_ARGS$; = --v
which was declared to be called as I have above and result in the output which I have also shown above.
In reply to Re: Read in a template file, populate using user input and and generate a new file
by hippo
in thread Read in a template file, populate using user input and and generate a new file
by Bioinfocoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |