As others have put - it is hard to tell where the spaces are coming from without more code. However, your replacement hash looks fine, so you probably have a sneaky space in your replacement code along the lines of (but a '#' instead of ' '):
my $string = '<TList.Bullet><TList.Item>sometext</TList.Item></TList.B +ullet>'; print "Before : \'$string\'\n"; my %find_replace = ( q[<TList.Bullet>] => q[<ul>], q[</TList.Bullet>] => q[</ul>], q[<TList.Item>] => q[<li>], q[</TList.Item>] => q[</li>], ); for (keys %find_replace){ $string =~ s/\Q$_\E/\#$find_replace{$_}/; } print "After : \'$string\'\n"; ## Gives : # Before : '<TList.Bullet><TList.Item>sometext</TList.Item></TList.Bul +let>' # After : '#<ul>#<li>sometext#</li>#</ul>'
But it woul help to see the replacement code and come real input / output.
Update : Forgot to include output... Now included with code.
In reply to Re: Remove blank space during find/replace
by BioLion
in thread Remove blank space during find/replace
by Melk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |