in reply to Double Interpolation of a String
For doing stuff with these kinds of substitutions, I always use code like this:
use strict; my %trans = (color => 'red', fruit => 'apple', name => 'chromatic'); my $string = 'Hi, my name is $name. Please hand me a $color $fruit.'; $string =~ s/\$(\w+)/$trans{$1}/eg; print $string;
--
<http://www.dave.org.uk>
European Perl Conference - Sept 22/24 2000
<http://www.yapc.org/Europe/>
|
---|
Replies are listed 'Best First'. | |
---|---|
Infinite Recursion of a String
by tadman (Prior) on Feb 07, 2001 at 00:30 UTC | |
by Fastolfe (Vicar) on Feb 07, 2001 at 00:34 UTC |
In Section
Snippets Section