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("", ); close (IN); # Note -- the 'master file' contains a variable, $account_number that needs to be substituted when the file contents are written into the variable, $new_file_content before writing this data into the $new_file_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; }