in reply to Regexp::Common

Here's a practical example:
use strict; use warnings; use Regexp::Common qw(URI); my @test_uris = ( # http 'http://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/C +ommon/URI.pm', 'https://your.bank.com/', # ftp 'ftp://ftp.server.com/notepad', 'ftp://ftp.server.com/notepad/notepad.cpp', 'ftp://jrs@ftp.server.com/notepad/notepad.cpp', 'ftp://jrs:wibble@ftp.server.com/notepad/notepad.cpp', 'ftp://jrs:*@ftp.server.com/notepad/notepad.cpp', # file 'file:///C:/jwmhome/www/perl/index.html', # nntp & news 'news:/comp.lang.*', 'news:/comp.*.java*', 'news:/*.religion.bahai,!talk.*', 'nntp://server.example/comp/lang.c', 'nntp://server.example/comp/lang.c/125-237', 'nntp://server.example/comp/lang.c/125-', 'nntp://server.example/comp/lang.c/-237', # bad http / https 'xhttp://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/ +Common/URI.pm', '<https://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp +/Common/URI.pm', # bad ftp 'xftp://ftp.server.com/notepad', '<ftp://ftp.server.com/notepad/notepad.cpp', '$ftp://jrs@ftp.server.com/notepad/notepad.cpp', '%ftp://jrs:wibble@ftp.server.com/notepad/notepad.cpp', ']ftp://jrs:*@ftp.server.com/notepad/notepad.cpp', ); for (@test_uris) { next if (/\A$RE{URI}{HTTP}{-scheme => qr(https?)}/ or /\A$RE{URI}{FTP}/ # or /$RE{URI}{file}/ # or /$RE{URI}{news}/ # or /$RE{URI}{NNTP}/ ); print 'not a URI: ', substr($_, 0, 40), "\n"; }