URI::F...imited(3pm)
πΈ URI::F...imited(3pm) β bestie edition πΈ
okay so this is the manual page for URI::F...imited, which lives in the User Contributed Perl Documentation corner of the perl universe. buckle up, we're finding links π
β¨ NAME β¨
URI::Find::Delimited β bestie, it finds URIs that might be wrapped up all cozy in enclosing delimiters π
π DESCRIPTION π
okay so it works exactly like URI::Find, but it's prepared. like, it knows your URIs in the text might be wrapped in a little pair of delimiters, and might optionally have a title too. this is lowkey so useful when you're processing text that already has some minimal markup going on β think bulletin board posts, wiki text, that kind of vibe. it's giving "I read the room" β¨
π¦ SYNOPSIS π¦
my $finder = URI::Find::Delimited->new;
my $text = "This is a [http://the.earth.li/ titled link].";
$finder->find(\$text);
print $text;
π METHODS π
new
my $finder = URI::Find::Delimited->new(
callback => \&callback,
delimiter_re => [ '\[', '\]' ],
ignore_quoted => 1 # defaults to 0
);
every single argument here is optional, no cap β defaults are provided and they're listed down below π
this makes you a brand new URI::Find::Delimited object. it works similarly to a URI::Find object, but on top of just looking for URIs, it also understands the whole concept of a wrapped, titled URI. those look something like this:
[http://foo.com/ the foo website]
and inside that little situation:
[is the opening delimiter]is the closing delimiterhttp://foo.com/is the URIthe foo websiteis the title- the URI and the title are separated by spaces and/or tabs
the URI::Find::Delimited object will pull each of those parts out separately and hand them over to your callback. iconic behaviour, honestly π«Ά
callback
callback is a function that gets called on every URI found. it gets passed five arguments: the opening delimiter (if one was found), the closing delimiter (if one was found), the URI, the title (if one was found), and any whitespace found between the URI and the title.
whatever your callback returns will replace the original URI in the text. main character energy π₯
if you don't supply your own callback, the object will make a default one for you. that default one puts your URIs in a href tags, using the URI as the target and the title as the link text. if a URI has no title, then the URI itself gets used as the title. and if the delimiters aren't balanced (like, say the opening one is there but no closing one shows up), then the URI gets treated as not being wrapped at all. fair enough π
Note: the default callback will not remove the delimiters from the text. if that's what you want, it should be simple enough to write your own callback to strip them out, based on the one in the source. there's literally an example in this distribution, in t/delimited.t. go look, i'll wait πΈ
delimiter_re
the delimiter_re parameter is optional. if you do supply it, it should be a ref to an array containing two regexes. it defaults to using single square brackets as the delimiters.
Don't use capturing groupings( )in your delimiters or things will break. use non-capturing(?: )instead. fr fr, this one matters π
ignore_quoted
if the ignore_quoted parameter is supplied and set to a true value, then any URIs immediately preceded by a double-quote character won't be matched. meaning: your callback will not be executed for them, and they'll just be treated like normal text. bye π
this is a bit of a hack but it's in here because the author needed to be able to ignore things like
<img src="http://foo.com/bar.gif">
a better implementation may happen at some point. we love an honest queen π
π SEE ALSO π
URI::Find.
π AUTHOR π
Kake Pugh (kake@earth.li).
π COPYRIGHT π
Copyright (C) 2003 Kake Pugh. All Rights Reserved.
this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay π
β CREDITS β
Tim Bagot helped stop the faffing over the name, by pointing out that RFC 2396 Appendix E uses "delimited". Dave Hinton helped fix the regex so it works for delimited URIs with no title. Nick Cleaton helped make ignore_quoted actually work. and some of the code was taken from URI::Find. a whole squad, honestly π«Ά
π POD ERRORS π
hey! the above document had some coding errors, which are explained below:
Around line 194:
You forgot a '=back' before '=head1'
and that's the whole page, bestie πΈ brought to you by perl v5.34.0, dated 2022-06-28. mwah, go find some URIs π β¨
π¦ where this page comes from
- debian bookworm: liburi-find-delimited-perl 0.03-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liburi-find-delimited-perl 0.03-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liburi-find-delimited-perl 0.03-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liburi-find-delimited-perl 0.03-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liburi-find-delimited-perl 0.03-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms