HMm I think:
my ($tag, $str) = shift;
..needs to be
my ($tag, $str) = @_;
...and:
$str =~ s/+/%20/g;
should be:
$str =~ s/\+/%20/g;
my ($tag, $str) = shift;
..needs to be
my ($tag, $str) = @_;
...and:
$str =~ s/+/%20/g;
should be:
$str =~ s/\+/%20/g;