in reply to Resolving Imbedded Variables
Alternatively, you might want something like this:my %data = ( ma_test => 1, mb_test => 'the RTE', ); my $text = 'titl=This is test $ma_test of $mb_test broadcasting system +'; $text =~ s/\$(\w+)/ $data{$1} /g; print $text;
my %data = ( ma_test => 1, mb_test => 'the RTE', ); my $text = 'titl=This is test $ma_test blah $x of $mb_test broadcastin +g system'; $text =~ s/\$(\w+)/ exists $data{lc $1} ? $data{lc $1} : '==VARIABLE_N +OT_FOUND==' /eg; print $text;
|
|---|