to:$string =~ s/##\s*([^#]+)\s*##/##$langhash{$1}##/
# v $string =~ s/##\s*([^#]+?)\s*##/##$langhash{$1}##/ # ^
You have asked for all of the non-number-symbol characters available and then spaces, but spaces are non-number-symbols characters. You're capturing your ending spaces in $1, then '\s*' comes up with nothing. There is no $langhash{dígito verificador incorrecto. '} or $langhash{dígito verificador incorrecto. '} or anything of that sort. Making the capture of non-number symbols non-greedy allows the '\s*' towards the end to match the spaces to the right of your match.
If you had used strictures and warnings as is often recommended here on PM, you would have received the same "Use of unitialized value in concatenation..." warnings I did running your original code.
In reply to Re: substitution not working correctly
by mr_mischief
in thread substitution not working correctly
by qnguyen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |