1URI::Heuristic(3) User Contributed Perl Documentation URI::Heuristic(3)
2
3
4
6 URI::Heuristic - Expand URI using heuristics
7
9 use URI::Heuristic qw(uf_uristr);
10 $u = uf_uristr("example"); # http://www.example.com
11 $u = uf_uristr("www.sol.no/sol"); # http://www.sol.no/sol
12 $u = uf_uristr("aas"); # http://www.aas.no
13 $u = uf_uristr("ftp.funet.fi"); # ftp://ftp.funet.fi
14 $u = uf_uristr("/etc/passwd"); # file:/etc/passwd
15
17 This module provides functions that expand strings into real absolute
18 URIs using some built-in heuristics. Strings that already represent
19 absolute URIs (i.e. that start with a "scheme:" part) are never
20 modified and are returned unchanged. The main use of these functions
21 is to allow abbreviated URIs similar to what many web browsers allow
22 for URIs typed in by the user.
23
24 The following functions are provided:
25
26 uf_uristr($str)
27 Tries to make the argument string into a proper absolute URI
28 string. The "uf_" prefix stands for "User Friendly". Under MacOS,
29 it assumes that any string with a common URL scheme (http, ftp,
30 etc.) is a URL rather than a local path. So don't name your
31 volumes after common URL schemes and expect uf_uristr() to
32 construct valid file: URL's on those volumes for you, because it
33 won't.
34
35 uf_uri($str)
36 Works the same way as uf_uristr() but returns a "URI" object.
37
39 If the hostname portion of a URI does not contain any dots, then
40 certain qualified guesses are made. These guesses are governed by the
41 following environment variables:
42
43 COUNTRY The two-letter country code (ISO 3166) for your location. If
44 the domain name of your host ends with two letters, then it
45 is taken to be the default country. See also Locale::Country.
46
47 HTTP_ACCEPT_LANGUAGE, LC_ALL, LANG
48 If COUNTRY is not set, these standard environment variables
49 are examined and country (not language) information possibly
50 found in them is used as the default country.
51
52 URL_GUESS_PATTERN
53 Contains a space-separated list of URL patterns to try. The
54 string "ACME" is for some reason used as a placeholder for
55 the host name in the URL provided. Example:
56
57 URL_GUESS_PATTERN="www.ACME.no www.ACME.se www.ACME.com"
58 export URL_GUESS_PATTERN
59
60 Specifying URL_GUESS_PATTERN disables any guessing rules
61 based on country. An empty URL_GUESS_PATTERN disables any
62 guessing that involves host name lookups.
63
65 Copyright 1997-1998, Gisle Aas
66
67 This library is free software; you can redistribute it and/or modify it
68 under the same terms as Perl itself.
69
70
71
72perl v5.36.0 2023-01-20 URI::Heuristic(3)