One way would be to read the file into a string, put qq (with a delimiter that doesn't occur in the file) around it, and eval it
$APPNAME = "AnyName"; open my $fh, "<", "prog_file" or die $!; my $lines; { local $/ = undef; $lines = <$fh>; } print eval "qq|$lines|";
Another way would be to put $lines = qq| ... |; around the entire content of the file (in the file itself), and then use do
$APPNAME = "AnyName"; do "prog_file"; print $lines;
A third way would be to use regex substitution to replace strings like $APPNAME in the lines, but only if unescaped...
But maybe what you're really looking for is a templating system, like Text::Template, the Template Toolkit, etc...
In reply to Re: Perl Script to write a perl script
by almut
in thread Perl Script to write a perl script
by electroman00
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |