URI::F...:Simple(3pm)

πŸ“¦
version 1.07 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 URI::F...:Simple(3pm) 🌸

okay bestie, welcome to URI::F...:Simple(3pm) β€” that's the manpage name right there in the corner, we're keeping it short and cute πŸ’–. This is the User Contributed Perl Documentation for URI::Find::Simple, and it's literally the low-effort, high-reward way to deal with links in text. no cap.


✨ 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>" } );

two functions, two vibes, zero callback chaos. periodt πŸ’…


✨ DESCRIPTION ✨

so like, URI::Find? iconic, no notes. BUT. sometimes you don't want the whole callback situation, you just want a list of the links sitting in some text, or you want to swap out every url in some text somehow, and you do not want to mess with callback interfaces. it's giving "I just want the uris bestie".

this module uses URI::Find, but it hides the callback interface and hands you two functions instead β€” one to list all the uris, and one to change all the uris. that's it, that's the whole deal 🌈

πŸŽ€ 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. so like, the glow-up version of the string, not the original. πŸ’…

πŸŽ€ change_uris( text, sub { code } )

the passed sub is called for every found uri in the text, and its return value is substituted into the string. returns the changed string. you hand it a little code block, it hands you back a whole new string. slay ✨


πŸ’€ CAVEATS, BUGS, ETC πŸ’€

real talk time, bestie, because we keep it honest here:

the change_uris function is only just nicer than the callback interface. in some ways it's actually 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 β€” that seemed to be the sensible thing. and 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. so heads up 🚨

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'.

so yeah. it can hand you back something different from what you gave it. that's not a bug, that's just the vibe. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

URI::Find, URI::Find::Iterator, URI, HTML::LinkExtor, HTML::LinkExtractor.

go read the family, they're all doing their thing 🫢


πŸ“¦ REPOSITORY πŸ“¦

<https://github.com/neilb/URI-Find-Simple>

the source lives here, go be nosy, I love that for you πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

Tom Insam <tom@jerakeen.org> inspired by Paul Mison <paul@husk.org>

This module is now maintained by Neil Bowers <neilb@cpan.org>.

shoutout to the originals and to the current maintainer keeping the lights on ⭐


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.


and that's the whole page, bestie!! no cap, you now know URI::F...:Simple(3pm) inside out πŸ¦‹

this gem was documented as perl v5.32.1, dated 2021-03-19, and the manpage title was literally URI::F...:Simple(3pm) β€” the ellipsis is doing its own thing, we respect it. πŸ’…βœ¨
πŸ“¦ where this page comes from