<?xml version="1.0" encoding="windows-1252"?>
<node id="1005243" title="Re: Efficient way to replace a set of values with another set of values" created="2012-11-23 05:12:01" updated="2012-11-23 05:12:01">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;Maybe a little something like this?&lt;/p&gt;
&lt;code&gt;
my $string = q{
1. This is just a sample.
2. This is to check 
3. How a set of values 
4. can be replaced by another 
5. set of values and that too 
6. in the most efficient way.
};
my %replacements = (
	'1.' =&gt; 'a.',
	'2.' =&gt; 'b.',
	'3.' =&gt; 'c.',
	'4.' =&gt; 'd.',
	'5.' =&gt; 'e.',
	'6.' =&gt; 'f.',
);

my $regexp = join '|', map quotemeta, keys %replacements;
$string =~ s/($regexp)/$replacements{$1}/g;

print $string;
&lt;/code&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005242</field>
<field name="parent_node">
1005242</field>
</data>
</node>
