#!/usr/bin/perl -w my %userInfo; $userInfo{fname} = '__fname__'; $userInfo{lname} = '__lname__'; $userInfo{email} = '__fullFrom__ <__email__>'; $fname = 'John'; $lname = 'Doe'; $fullFrom = join(' ', $fname, $lname); $email = 'john@doe.com'; foreach my $key (keys %userInfo) { $userInfo{$key} =~ s/__([^_]+)__/${$1}/g; print $userInfo{$key}, "\n"; } C:\>perl test.pl Name "main::fullFrom" used only once: possible typo at test.pl line 11. Name "main::email" used only once: possible typo at test.pl line 12. John John Doe Doe C:\>