From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

url - format a URL according to a sprintf-like template

SYNOPSIS

# format as just the host
www.example.com
# handle more than one.
www.example.com
www.github.com
# get the path
/a/b/c

DESCRIPTION

Decompose the URL and reformat it according to a template.

The formats

  • %a - the path

  • %A - the addresses

  • %f - the fragment

  • %h - the hostname, with domain info

  • %H - the hostname without domain info

  • %i - the hostname in punycode

  • %I - space-separated list of IP addresses for the host

  • %P - the password of the userinfo portion

  • %p - the port

  • %q - the query string

  • %s - the scheme

  • %S - the public suffix

  • %u - the complete URL

  • %U - the username of the userinfo portion

COPYRIGHT

Copyright © 2020-2025, brian d foy, all rights reserved.

LICENSE

You can use this code under the terms of the Artistic License 2.