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

Hello Monks,

I am learning Perl.

What are the useful of Regexp::Common module.

Can u give small Coding.. So that it'll be very Helpfull to develop further...

Thanks So Much!!

Replies are listed 'Best First'.
Re: Regexp::Common
by holli (Abbot) on Feb 26, 2005 at 12:28 UTC
    I recommend reading the documentatin of the module. Many examples there are.

    holli, /regexed monk/
Re: Regexp::Common
by sh1tn (Priest) on Feb 26, 2005 at 14:03 UTC
      Urg. Those are test scripts that seem to generate all (or most) of the tests on the fly. Not very useful as examples. Most of what's found in the /t directory of Regexp::Common looks freakish - not the place I'd go to to get examples.
Re: Regexp::Common
by jmccarrell (Novice) on Sep 28, 2007 at 06:22 UTC
    Here's a practical example:
    use strict; use warnings; use Regexp::Common qw(URI); my @test_uris = ( # http ' +ommon/', '', # ftp '', '', '', '', 'ftp://jrs:*', # 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 'x +Common/', '< +/Common/', # bad ftp 'x', '<', '$', '%', ']ftp://jrs:*', ); 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"; }