http://www.perlmonks.org?node_id=963124

slugger415 has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear monks, a user of a script I've written that uses the URI::Escape module keeps getting an error:

Undefined subroutine &URI::Escape::uri_escape_utf8 called at myscript.pl line 375.

I cannot duplicate this error on my machine. I use it thusly:

use URI::Escape; ## lots of other stuff ## $booktitle = URI::Escape::uri_escape_utf8($booktitle);

I'd also used it like so, without the prefix:

$booktitle = uri_escape_utf8($booktitle);

Someone else reported a similar error with that syntax, and it was fixed when I added the URI::Escape prefix to the call.

We're both running ActivePerl, he 5.8 and I 5.12, does that make a difference? Is there something I'm missing?

thanks very much -- Scott

Replies are listed 'Best First'.
Re: Puzzling URI::Escape problem
by tobyink (Canon) on Apr 02, 2012 at 22:15 UTC

    Very old version of URI::Escape? uri_escape_utf8 has been exported by default since version 1.36.

    It's easy enough to explicitly request it to be exported:

    use URI::Escape qw(uri_escape uri_escape_utf8);
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Considering Perl 5.8 is ancient, the version of URI installed on that might not even have uri_escape_utf8. It was added in URI 1.31. You can explicitly require minimum module versions like so: use URI 1.36;

      Yes it looks like the ancient Perl was the culprit. Thanks for the quick responses!

        Yes it looks like the ancient Perl was the culprit. Thanks for the quick responses!

        :) Considering URI doesn't come with Perl, its available on CPAN, the ancient version of URI was the culprit