my $text = "Insert $id here!\n"; my %values = ( id => 10 ); $text =~ s/\$(\w+)\b/$values{$1}/g; print $text, "\n";