newbie00 has asked for the wisdom of the Perl Monks concerning the following question:

I have created generic text files, scripts, etc. in order to perform quick installs of the software to various subdirectories.

I inserted variables (e.g. account number) in specific locations within each file, and upon running the install script, I want the 'values' of these variables inserted. But, what is happening is that the raw variables are printed without interpretation.

Here is a sample of the code:
~~~~~~~~~~~~~~~~~~~~~~

sub newfile_create { $account_number = "12345"; $master_file = "/usr/local/foo/htdocs/master_file.txt"; open (IN, "$master_file") or die "Couldn't open file: $!"; $new_file_content = join("", <IN>); close (IN); # Note -- the 'master file' contains a variable, $account_number that +needs to be substituted when the file contents are written into the v +ariable, $new_file_content before writing this data into the $new_fil +e_path location (file). $new_file_path = "/usr/local/foo/htdocs/sub/file1.js"; open(IN, ">$new_file_path"); print IN "$new_file_content"; close(IN); return; }

~~~~~~~~~~~~~~~~~~~~~~
How can I get the $account_number var interpreted before writing to the new file?

Thank you.

Replies are listed 'Best First'.
Re: How to interpret a variable from a file vs printing the var?
by japhy (Canon) on Dec 09, 2001 at 22:32 UTC
    This in the FAQ. Please use the search tool to see if your question has already been asked (and answered!) before posting.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;