in reply to substitution not working correctly
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution not working correctly
by qnguyen (Acolyte) on Sep 23, 2007 at 21:49 UTC | |
by ikegami (Patriarch) on Sep 23, 2007 at 22:25 UTC | |
by qnguyen (Acolyte) on Sep 24, 2007 at 13:25 UTC | |
by ikegami (Patriarch) on Sep 24, 2007 at 14:06 UTC | |
by qnguyen (Acolyte) on Sep 24, 2007 at 15:10 UTC | |
|