URLデコード

非破壊的な置換ってどうやるんだろう?

#!/usr/bin/env perl
use warnings;
use strict;
use Carp;

sub url_decode {
  my ($str) = @_;
  $str =~ s/%([\da-f]{2})/pack('C', hex($1))/egi;
  return $str;
}

my $x = "%83E%83B%83L%83y%83f%83B%83A";
print url_decode($x), "\n";