-
-
14 Mar 2021 23:43:48 UTC
- Distribution: URI-Find-Simple
- Module version: 1.07
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (263 / 0 / 0)
- Kwalitee
Bus factor: 1- 98.33% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (4.16KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Encode
- URI::Find
- strict
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
URI::Find::Simple - a simple interface to URI::Find
SYNOPSIS
use URI::Find::Simple qw( list_uris ); my @list = list_uris($text); my $html = change_uris($text, sub { "<a href=\"$_[0]\">$_[0]</a>" } );
DESCRIPTION
URI::Find is all very well, but sometimes you just want a list of the links in a given piece of text, or you want to change all the urls in some text somehow, and don't want to mess with callback interfaces.
This module uses URI::Find, but hides the callback interface, providing two functions - one to list all the uris, and one to change all the uris.
list_uris( text )
returns a list of all the uris in the passed string, in the form output by the URI->as_string function, not the form that they exist in the text.
change_uris( text, sub { code } )
the passed sub is called for every found uri in the text, and it's return value is substituted into the string. Returns the changed string.
CAVEATS, BUGS, ETC
The change_uris function is only just nicer than the callback interface. In some ways it's worse. I's prefer to just pass an s/// operator somehow, but I don't think that's possible.
The list_uris function returns the stringified versions of the URI objects, this seemed to be the sensible thing. To present a consistent interface, the change_uris function operates on these strings as well, which are not the same as the strings actually present in the original. Therefore this code:
my $text = change_uris($text, sub { shift } );
may not return the same thing you pass it. URIs such as <URI:http://jerakeen.org> will be converted to the string 'http://jerakeen.org'.
SEE ALSO
URI::Find, URI::Find::Iterator, URI, HTML::LinkExtor, HTML::LinkExtractor.
REPOSITORY
https://github.com/neilb/URI-Find-Simple
AUTHOR
Tom Insam <tom@jerakeen.org> inspired by Paul Mison <paul@husk.org>
This module is now maintained by Neil Bowers <neilb@cpan.org>.
COPYRIGHT AND LICENSE
Copyright (c) 2004 Tom Insam <tom@jerakeen.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install URI::Find::Simple, copy and paste the appropriate command in to your terminal.
cpanm URI::Find::Simple
perl -MCPAN -e shell install URI::Find::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.