do 'mycode.pl'; #### use strict; use warnings; my ($handle, %hash); ###### Collect template contents and change to string open($handle, 'template.dat'); $_ = join '', <$handle>; close($handle); ###### Some dummy values to insert in the template $hash{'name'} = 'Theodore'; $hash{'age'} = 26; ###### Every instance of %hashkey% is replaced with ###### the corresponding value { no warnings; s/%(\w+)%/$hash{$1}/g; } print;