in reply to Debug and workaround help

Add \Q...\E in the search pattern. Now you will get the correct output.

$string =~ s/\Q$str2Brepl\E/$strRepl/mi; print "$string";

Prasad

Replies are listed 'Best First'.
Re^2: Debug and workaround help
by Anonymous Monk on Jun 28, 2005 at 06:30 UTC
    The Functionality works if the $string value is changed to as below
    my $string ='<item name="a"><text></text></item><vertical name="Busine +sses" combination="and"> <Busines name="Content"> <BusinessNames min-entity="1" max-entity="10">';

    I think the "</description>" needs to be handled differently in the search and replace regex.

      After removing the description part, you are getting correct output, because it has special characters which has to be escaped. Whenever if you have any special characters in the search pattern you need to use \Q...\E. You go through perlre.

      Prasad