use Text::Template; my $template = Text::Template->new( type => "FILEHANDLE", source => *DATA, ); my $text = $template->fill_in( hash => { placeholder1 => "chicken", placeholder2 => "dog", }, ); print $text; __END__ This is text with { $placeholder1 }. It can be with { $placeholder2 } too. { $placeholder1 } can appear more than one time in the text.