The perl1 version of this perl5 code
sub UnEscape {
my $str = shift;
$str =~ s/%(\w\w)/sprintf("%c", hex($1))/eg;
$str;
}
Is something like the following. Note how substr isn't quite as nice as you'd expect.
sub UnEscape {
$str = $_[0];
$pos = index($str, '%');
while ($pos != -1) {
$code = sprintf("%c", hex(substr($str, $pos + 1, 2)));
$str = substr($str, 0, $pos).$code.substr($str, $pos + 3, length($str));
$pos = index($str, '%');
}
$str;
}
Bug (Score:1)
I have no idea if substr() in this ancient version of the language could actually handle that.
s///ge (Score:1)
Re:s///ge (Score:1)
Tested with:
No longer works with recent Perls, because those don't allow clearing $n manually. In Perl 1, you had to, because otherw