in reply to search replace (interpolation)
First using symbolic references in this way is a hallmark of bad program design. There really is not any good reason to do it the way you are trying to. See this excelent article Why it's stupid to use a variable as a variable name
Anyway it will work if you remove the my declarations as shown:
#!/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 <john@doe.com> Doe C:\>
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|