use strict; use warnings; use URI::URL; use feature 'say'; use utf8; binmode STDOUT,'utf8'; my %TESTS = ( 'http://müller.de' => 'http://xn--mller-kva.de/', 'http://موقع.وزارة-الاتصالات.مصر' => 'http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/', 'http://правительство.рф' => 'http://xn--80aealotwbjpid2k.xn--p1ai/', 'http://北京大学.cn' => 'http://xn--1lq90ic7fzpc.cn/', ); say "\n", '-'x10; say '### Test URI::URL Punycode'; for my $key (keys %TESTS) { my $u = URI::URL->new($key); print "$key ", $u eq $TESTS{$key} ? 'OK' : 'FAIL', "\n"; } ####################### use lib 'uri-find/lib'; use URI::Find; say "\n", '-'x10; say '### Test URI::Find with IDNA domains'; my $finder = URI::Find->new(sub { my($uri, $orig_uri) = @_; say $uri eq $TESTS{$orig_uri} ? "OK '$uri is $orig_uri'" : "FAIL"; return $orig_uri; }); my $text = join " ",keys %TESTS; $finder->find(\$text); #################### use URI::Find::Schemeless; my %TESTS2 = ( 'müller.de' => 'http://xn--mller-kva.de/', 'موقع.وزارة-الاتصالات.مصر' => 'http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/', 'правительство.рф' => 'http://xn--80aealotwbjpid2k.xn--p1ai/', '北京大学.cn' => 'http://xn--1lq90ic7fzpc.cn/', ); say "\n", '-'x10; say '### Test URI::Find::Schemeless with IDNA domains'; my $finder2 = URI::Find::Schemeless->new(sub { my($uri, $orig_uri) = @_; say $uri eq $TESTS2{$orig_uri} ? "OK '$uri is $orig_uri'" : "FAIL"; return $orig_uri; }); $text = join " ",keys %TESTS2; $finder2->find(\$text); 1;