http://qs321.pair.com?node_id=556890


in reply to Regex to replace a particular part of content

my $bla = qq+The quick brown fox jumps over the lazy dog. The quick br +own fox jumps over the lazy dog. The quick brown fox jumps over the l +azy dog. The quick brown fox jumps over the lazy dog. The quick brown + fox jumps over the lazy dog. The quick brown fox jumps over the lazy + dog. <list>The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</list> The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps ov +er the lazy dog. The quick brown fox jumps over the lazy dog.+; $bla =~ s~(<list>)(.*?)(</list>)~$1.subst($2).$3~es; print $bla; sub subst{ my ($string) = @_; print $string; my $res = ""; for(split(/\n/,$string)){ $res .= '<item>'.$_.'</item>'."\n"; } return $res; }