URI::Find::Rule(3)    User Contributed Perl Documentation   URI::Find::Rule(3)



NNAAMMEE
       URI::Find::Rule - Simpler interface to URI::Find

SSYYNNOOPPSSIISS
         use URI::Find::Rule;
         # find all the http URIs in some text
         my @uris = URI::Find::Rule->scheme('http')->in($text);
         # or you can use anything that URI->can() for HTTP URIs
         my @uris = URI::Find::Rule->http->in($text);

         # find all the URIs referencing a host
         my @uris = URI::Find::Rule->host(qr/myhost/)->in($text);

DDEESSCCRRIIPPTTIIOONN
       URI::Find::Rule is a simpler interface to URI::Find (closely modelled
       on File::Find::Rule by Richard Clamp).

       Because it operates on URI objects instead of the stringified versions
       of the found URIs, it's nicer than, say, grepping the stringified val-
       ues from URI::Find::Simple's "list_uris" method.

       It returns (default) a list containing "[$original, $uri]" for each URI
       or, optionally, a list containing a URI object for each URI.

MMEETTHHOODDSS
       Apart from "in", all the methods can take multiple strings or regexps
       to match against, e.g.

         ->scheme('http')          # match against the single string 'http'
         ->scheme('http','ftp')    # match either string 'http' or 'ftp'
         ->scheme(qr/tp$/, 'ldap') # match /tp$/ or the string 'ldap'

       They can also be combined to provide more selective filtering, e.g.

         ->scheme('ftp')->host('pi.st') # match FTP URIs with a host of pi.st

       The filtering is done by checking against the corresponding methods
       called on the URI object so almost anything (see BUGS) you can do with
       a URI object, you can filter on.

       Only a few methods are listed, for more examples check the tests.

       iinn

         URI::Find::Rule->in($text);

       With a single argument, returns a list of anonymous arrays containing
       "($original_text, $uri)" for each URI found in $text.

         URI::Find::Rule->in($text, 'objects');

       With a true-valued second argument, it returns a list of URI objects,
       one for each URI found in $text.

       sscchheemmee

         URI::Find::Rule->scheme('http')->in($text);

       Filters the URIs found based on their scheme.

       hhoosstt

         URI::Find::Rule->host('pi.st')->in($text);

       Filters the URIs found based on their parsed hostname.

       pprroottooccooll

         URI::Find::Rule->protocol('http')->in($text);

       A convenient alias for "scheme".

       ootthheerr mmeetthhooddss

         ->ldap('pi.st') # converts to ->scheme('ldap')->host('pi.st')

       Any unrecognised method will be converted to
       "->scheme($method)->host(@_)" for convenience.

BBUUGGSS
       "URI->can()" needs a URI before it'll respond -- at the moment, this is
       "http://x:y@a/b#c?d" which means that any of the scheme-specific meth-
       ods (like "$uri->dn" for LDAP URIs can't be used.)

       There's no "->not" functionality at the moment or any kind of logical
       combining other than the simplistic OR of "->thing('this','that')".

       The anonymous arrays contain the original text and the stringified URI
       in reverse order when compared with URI::Find's callback.  This may
       confuse.

CCRREEDDIITTSS
       Richard Clamp (patches, code to cargo cult from)

LLIICCEENNSSEE
       This module is free software, and may be distributed under the same
       terms as Perl itself.

AAUUTTHHOORR
       Copyright (C) 2004, Rob Partington <perl-ufr@frottage.org>



perl v5.8.4                       2004-08-14                URI::Find::Rule(3)
