#!/usr/bin/env perl use strict; use warnings; undef $/; my %vars = ( name => qq(Karl), color => qq(blue), fruit => qq(tomato) ); my $string = ; $string =~ s/%%(.*?)%%/$vars{$1}/gs; print $string; __DATA__ Hello, my name is %%name%%! May i have a %%color%% %%fruit%% please?