open my $FILE, '<', $name_of_file_with_functions_in_it or die ("Crap: $!"); while (<$FILE>) { s/\bC\b/$z/g; # replace the *word* "C" with the contents of $z print $_; } close $FILE;