1URI(3)                User Contributed Perl Documentation               URI(3)
2
3
4

NAME

6       URI - Uniform Resource Identifiers (absolute and relative)
7

SYNOPSIS

9        use URI ();
10
11        $u1 = URI->new("http://www.example.com");
12        $u2 = URI->new("foo", "http");
13        $u3 = $u2->abs($u1);
14        $u4 = $u3->clone;
15        $u5 = URI->new("HTTP://WWW.example.com:80")->canonical;
16
17        $str = $u->as_string;
18        $str = "$u";
19
20        $scheme = $u->scheme;
21        $opaque = $u->opaque;
22        $path   = $u->path;
23        $frag   = $u->fragment;
24
25        $u->scheme("ftp");
26        $u->host("ftp.example.com");
27        $u->path("cpan/");
28

DESCRIPTION

30       This module implements the "URI" class.  Objects of this class
31       represent "Uniform Resource Identifier references" as specified in RFC
32       2396 (and updated by RFC 2732).
33
34       A Uniform Resource Identifier is a compact string of characters that
35       identifies an abstract or physical resource.  A Uniform Resource
36       Identifier can be further classified as either a Uniform Resource
37       Locator (URL) or a Uniform Resource Name (URN).  The distinction
38       between URL and URN does not matter to the "URI" class interface. A
39       "URI-reference" is a URI that may have additional information attached
40       in the form of a fragment identifier.
41
42       An absolute URI reference consists of three parts:  a scheme, a scheme-
43       specific part and a fragment identifier.  A subset of URI references
44       share a common syntax for hierarchical namespaces.  For these, the
45       scheme-specific part is further broken down into authority, path and
46       query components.  These URIs can also take the form of relative URI
47       references, where the scheme (and usually also the authority) component
48       is missing, but implied by the context of the URI reference.  The three
49       forms of URI reference syntax are summarized as follows:
50
51         <scheme>:<scheme-specific-part>#<fragment>
52         <scheme>://<authority><path>?<query>#<fragment>
53         <path>?<query>#<fragment>
54
55       The components into which a URI reference can be divided depend on the
56       scheme.  The "URI" class provides methods to get and set the individual
57       components.  The methods available for a specific "URI" object depend
58       on the scheme.
59

CONSTRUCTORS

61       The following methods construct new "URI" objects:
62
63       $uri = URI->new( $str )
64       $uri = URI->new( $str, $scheme )
65           Constructs a new URI object.  The string representation of a URI is
66           given as argument, together with an optional scheme specification.
67           Common URI wrappers like "" and <>, as well as leading and trailing
68           white space, are automatically removed from the $str argument
69           before it is processed further.
70
71           The constructor determines the scheme, maps this to an appropriate
72           URI subclass, constructs a new object of that class and returns it.
73
74           If the scheme isn't one of those that URI recognizes, you still get
75           an URI object back that you can access the generic methods on.  The
76           "$uri->has_recognized_scheme" method can be used to test for this.
77
78           The $scheme argument is only used when $str is a relative URI.  It
79           can be either a simple string that denotes the scheme, a string
80           containing an absolute URI reference, or an absolute "URI" object.
81           If no $scheme is specified for a relative URI $str, then $str is
82           simply treated as a generic URI (no scheme-specific methods
83           available).
84
85           The set of characters available for building URI references is
86           restricted (see URI::Escape).  Characters outside this set are
87           automatically escaped by the URI constructor.
88
89       $uri = URI->new_abs( $str, $base_uri )
90           Constructs a new absolute URI object.  The $str argument can denote
91           a relative or absolute URI.  If relative, then it is absolutized
92           using $base_uri as base. The $base_uri must be an absolute URI.
93
94       $uri = URI::file->new( $filename )
95       $uri = URI::file->new( $filename, $os )
96           Constructs a new file URI from a file name.  See URI::file.
97
98       $uri = URI::file->new_abs( $filename )
99       $uri = URI::file->new_abs( $filename, $os )
100           Constructs a new absolute file URI from a file name.  See
101           URI::file.
102
103       $uri = URI::file->cwd
104           Returns the current working directory as a file URI.  See
105           URI::file.
106
107       $uri->clone
108           Returns a copy of the $uri.
109

COMMON METHODS

111       The methods described in this section are available for all "URI"
112       objects.
113
114       Methods that give access to components of a URI always return the old
115       value of the component.  The value returned is "undef" if the component
116       was not present.  There is generally a difference between a component
117       that is empty (represented as "") and a component that is missing
118       (represented as "undef").  If an accessor method is given an argument,
119       it updates the corresponding component in addition to returning the old
120       value of the component.  Passing an undefined argument removes the
121       component (if possible).  The description of each accessor method
122       indicates whether the component is passed as an escaped (percent-
123       encoded) or an unescaped string.  A component that can be further
124       divided into sub-parts are usually passed escaped, as unescaping might
125       change its semantics.
126
127       The common methods available for all URI are:
128
129       $uri->scheme
130       $uri->scheme( $new_scheme )
131           Sets and returns the scheme part of the $uri.  If the $uri is
132           relative, then $uri->scheme returns "undef".  If called with an
133           argument, it updates the scheme of $uri, possibly changing the
134           class of $uri, and returns the old scheme value.  The method croaks
135           if the new scheme name is illegal; a scheme name must begin with a
136           letter and must consist of only US-ASCII letters, numbers, and a
137           few special marks: ".", "+", "-".  This restriction effectively
138           means that the scheme must be passed unescaped.  Passing an
139           undefined argument to the scheme method makes the URI relative (if
140           possible).
141
142           Letter case does not matter for scheme names.  The string returned
143           by $uri->scheme is always lowercase.  If you want the scheme just
144           as it was written in the URI in its original case, you can use the
145           $uri->_scheme method instead.
146
147       $uri->has_recognized_scheme
148           Returns TRUE if the URI scheme is one that URI recognizes.
149
150           It will also be TRUE for relative URLs where a recognized scheme
151           was provided to the constructor, even if "$uri->scheme" returns
152           "undef" for these.
153
154       $uri->opaque
155       $uri->opaque( $new_opaque )
156           Sets and returns the scheme-specific part of the $uri (everything
157           between the scheme and the fragment) as an escaped string.
158
159       $uri->path
160       $uri->path( $new_path )
161           Sets and returns the same value as $uri->opaque unless the URI
162           supports the generic syntax for hierarchical namespaces.  In that
163           case the generic method is overridden to set and return the part of
164           the URI between the host name and the fragment.
165
166       $uri->fragment
167       $uri->fragment( $new_frag )
168           Returns the fragment identifier of a URI reference as an escaped
169           string.
170
171       $uri->as_string
172           Returns a URI object to a plain ASCII string.  URI objects are also
173           converted to plain strings automatically by overloading.  This
174           means that $uri objects can be used as plain strings in most Perl
175           constructs.
176
177       $uri->as_iri
178           Returns a Unicode string representing the URI.  Escaped UTF-8
179           sequences representing non-ASCII characters are turned into their
180           corresponding Unicode code point.
181
182       $uri->canonical
183           Returns a normalized version of the URI.  The rules for
184           normalization are scheme-dependent.  They usually involve
185           lowercasing the scheme and Internet host name components, removing
186           the explicit port specification if it matches the default port,
187           uppercasing all escape sequences, and unescaping octets that can be
188           better represented as plain characters.
189
190           For efficiency reasons, if the $uri is already in normalized form,
191           then a reference to it is returned instead of a copy.
192
193       $uri->eq( $other_uri )
194       URI::eq( $first_uri, $other_uri )
195           Tests whether two URI references are equal.  URI references that
196           normalize to the same string are considered equal.  The method can
197           also be used as a plain function which can also test two string
198           arguments.
199
200           If you need to test whether two "URI" object references denote the
201           same object, use the '==' operator.
202
203       $uri->abs( $base_uri )
204           Returns an absolute URI reference.  If $uri is already absolute,
205           then a reference to it is simply returned.  If the $uri is
206           relative, then a new absolute URI is constructed by combining the
207           $uri and the $base_uri, and returned.
208
209       $uri->rel( $base_uri )
210           Returns a relative URI reference if it is possible to make one that
211           denotes the same resource relative to $base_uri.  If not, then $uri
212           is simply returned.
213
214       $uri->secure
215           Returns a TRUE value if the URI is considered to point to a
216           resource on a secure channel, such as an SSL or TLS encrypted one.
217

GENERIC METHODS

219       The following methods are available to schemes that use the
220       common/generic syntax for hierarchical namespaces.  The descriptions of
221       schemes below indicate which these are.  Unrecognized schemes are
222       assumed to support the generic syntax, and therefore the following
223       methods:
224
225       $uri->authority
226       $uri->authority( $new_authority )
227           Sets and returns the escaped authority component of the $uri.
228
229       $uri->path
230       $uri->path( $new_path )
231           Sets and returns the escaped path component of the $uri (the part
232           between the host name and the query or fragment).  The path can
233           never be undefined, but it can be the empty string.
234
235       $uri->path_query
236       $uri->path_query( $new_path_query )
237           Sets and returns the escaped path and query components as a single
238           entity.  The path and the query are separated by a "?" character,
239           but the query can itself contain "?".
240
241       $uri->path_segments
242       $uri->path_segments( $segment, ... )
243           Sets and returns the path.  In a scalar context, it returns the
244           same value as $uri->path.  In a list context, it returns the
245           unescaped path segments that make up the path.  Path segments that
246           have parameters are returned as an anonymous array.  The first
247           element is the unescaped path segment proper;  subsequent elements
248           are escaped parameter strings.  Such an anonymous array uses
249           overloading so it can be treated as a string too, but this string
250           does not include the parameters.
251
252           Note that absolute paths have the empty string as their first
253           path_segment, i.e. the path "/foo/bar" have 3 path_segments; "",
254           "foo" and "bar".
255
256       $uri->query
257       $uri->query( $new_query )
258           Sets and returns the escaped query component of the $uri.
259
260       $uri->query_form
261       $uri->query_form( $key1 => $val1, $key2 => $val2, ... )
262       $uri->query_form( $key1 => $val1, $key2 => $val2, ..., $delim )
263       $uri->query_form( \@key_value_pairs )
264       $uri->query_form( \@key_value_pairs, $delim )
265       $uri->query_form( \%hash )
266       $uri->query_form( \%hash, $delim )
267           Sets and returns query components that use the
268           application/x-www-form-urlencoded format.  Key/value pairs are
269           separated by "&", and the key is separated from the value by a "="
270           character.
271
272           The form can be set either by passing separate key/value pairs, or
273           via an array or hash reference.  Passing an empty array or an empty
274           hash removes the query component, whereas passing no arguments at
275           all leaves the component unchanged.  The order of keys is undefined
276           if a hash reference is passed.  The old value is always returned as
277           a list of separate key/value pairs.  Assigning this list to a hash
278           is unwise as the keys returned might repeat.
279
280           The values passed when setting the form can be plain strings or
281           references to arrays of strings.  Passing an array of values has
282           the same effect as passing the key repeatedly with one value at a
283           time.  All the following statements have the same effect:
284
285               $uri->query_form(foo => 1, foo => 2);
286               $uri->query_form(foo => [1, 2]);
287               $uri->query_form([ foo => 1, foo => 2 ]);
288               $uri->query_form([ foo => [1, 2] ]);
289               $uri->query_form({ foo => [1, 2] });
290
291           The $delim parameter can be passed as ";" to force the key/value
292           pairs to be delimited by ";" instead of "&" in the query string.
293           This practice is often recommended for URLs embedded in HTML or XML
294           documents as this avoids the trouble of escaping the "&" character.
295           You might also set the $URI::DEFAULT_QUERY_FORM_DELIMITER variable
296           to ";" for the same global effect.
297
298       @keys = $u->query_param
299       @values = $u->query_param( $key )
300       $first_value = $u->query_param( $key )
301       $u->query_param( $key, $value,... )
302           If $u->query_param is called with no arguments, it returns all the
303           distinct parameter keys of the URI.  In a scalar context it returns
304           the number of distinct keys.
305
306           When a $key argument is given, the method returns the parameter
307           values with the given key.  In a scalar context, only the first
308           parameter value is returned.
309
310           If additional arguments are given, they are used to update
311           successive parameters with the given key.  If any of the values
312           provided are array references, then the array is dereferenced to
313           get the actual values.
314
315           Please note that you can supply multiple values to this method, but
316           you cannot supply multiple keys.
317
318           Do this:
319
320               $uri->query_param( widget_id => 1, 5, 9 );
321
322           Do NOT do this:
323
324               $uri->query_param( widget_id => 1, frobnicator_id => 99 );
325
326       $u->query_param_append($key, $value,...)
327           Adds new parameters with the given key without touching any old
328           parameters with the same key.  It can be explained as a more
329           efficient version of:
330
331              $u->query_param($key,
332                              $u->query_param($key),
333                              $value,...);
334
335           One difference is that this expression would return the old values
336           of $key, whereas the query_param_append() method does not.
337
338       @values = $u->query_param_delete($key)
339       $first_value = $u->query_param_delete($key)
340           Deletes all key/value pairs with the given key.  The old values are
341           returned.  In a scalar context, only the first value is returned.
342
343           Using the query_param_delete() method is slightly more efficient
344           than the equivalent:
345
346              $u->query_param($key, []);
347
348       $hashref = $u->query_form_hash
349       $u->query_form_hash( \%new_form )
350           Returns a reference to a hash that represents the query form's
351           key/value pairs.  If a key occurs multiple times, then the hash
352           value becomes an array reference.
353
354           Note that sequence information is lost.  This means that:
355
356              $u->query_form_hash($u->query_form_hash);
357
358           is not necessarily a no-op, as it may reorder the key/value pairs.
359           The values returned by the query_param() method should stay the
360           same though.
361
362       $uri->query_keywords
363       $uri->query_keywords( $keywords, ... )
364       $uri->query_keywords( \@keywords )
365           Sets and returns query components that use the keywords separated
366           by "+" format.
367
368           The keywords can be set either by passing separate keywords
369           directly or by passing a reference to an array of keywords.
370           Passing an empty array removes the query component, whereas passing
371           no arguments at all leaves the component unchanged.  The old value
372           is always returned as a list of separate words.
373

SERVER METHODS

375       For schemes where the authority component denotes an Internet host, the
376       following methods are available in addition to the generic methods.
377
378       $uri->userinfo
379       $uri->userinfo( $new_userinfo )
380           Sets and returns the escaped userinfo part of the authority
381           component.
382
383           For some schemes this is a user name and a password separated by a
384           colon.  This practice is not recommended. Embedding passwords in
385           clear text (such as URI) has proven to be a security risk in almost
386           every case where it has been used.
387
388       $uri->host
389       $uri->host( $new_host )
390           Sets and returns the unescaped hostname.
391
392           If the $new_host string ends with a colon and a number, then this
393           number also sets the port.
394
395           For IPv6 addresses the brackets around the raw address is removed
396           in the return value from $uri->host.  When setting the host
397           attribute to an IPv6 address you can use a raw address or one
398           enclosed in brackets.  The address needs to be enclosed in brackets
399           if you want to pass in a new port value as well.
400
401       $uri->ihost
402           Returns the host in Unicode form.  Any IDNA A-labels are turned
403           into U-labels.
404
405       $uri->port
406       $uri->port( $new_port )
407           Sets and returns the port.  The port is a simple integer that
408           should be greater than 0.
409
410           If a port is not specified explicitly in the URI, then the URI
411           scheme's default port is returned. If you don't want the default
412           port substituted, then you can use the $uri->_port method instead.
413
414       $uri->host_port
415       $uri->host_port( $new_host_port )
416           Sets and returns the host and port as a single unit.  The returned
417           value includes a port, even if it matches the default port.  The
418           host part and the port part are separated by a colon: ":".
419
420           For IPv6 addresses the bracketing is preserved; thus
421           URI->new("http://[::1]/")->host_port returns "[::1]:80".  Contrast
422           this with $uri->host which will remove the brackets.
423
424       $uri->default_port
425           Returns the default port of the URI scheme to which $uri belongs.
426           For http this is the number 80, for ftp this is the number 21, etc.
427           The default port for a scheme can not be changed.
428

SCHEME-SPECIFIC SUPPORT

430       Scheme-specific support is provided for the following URI schemes.  For
431       "URI" objects that do not belong to one of these, you can only use the
432       common and generic methods.
433
434       data:
435           The data URI scheme is specified in RFC 2397.  It allows inclusion
436           of small data items as "immediate" data, as if it had been included
437           externally.
438
439           "URI" objects belonging to the data scheme support the common
440           methods and two new methods to access their scheme-specific
441           components: $uri->media_type and $uri->data.  See URI::data for
442           details.
443
444       file:
445           An old specification of the file URI scheme is found in RFC 1738.
446           A new RFC 2396 based specification in not available yet, but file
447           URI references are in common use.
448
449           "URI" objects belonging to the file scheme support the common and
450           generic methods.  In addition, they provide two methods for mapping
451           file URIs back to local file names; $uri->file and $uri->dir.  See
452           URI::file for details.
453
454       ftp:
455           An old specification of the ftp URI scheme is found in RFC 1738.  A
456           new RFC 2396 based specification in not available yet, but ftp URI
457           references are in common use.
458
459           "URI" objects belonging to the ftp scheme support the common,
460           generic and server methods.  In addition, they provide two methods
461           for accessing the userinfo sub-components: $uri->user and
462           $uri->password.
463
464       gopher:
465           The gopher URI scheme is specified in
466           <draft-murali-url-gopher-1996-12-04> and will hopefully be
467           available as a RFC 2396 based specification.
468
469           "URI" objects belonging to the gopher scheme support the common,
470           generic and server methods. In addition, they support some methods
471           for accessing gopher-specific path components: $uri->gopher_type,
472           $uri->selector, $uri->search, $uri->string.
473
474       http:
475           The http URI scheme is specified in RFC 2616.  The scheme is used
476           to reference resources hosted by HTTP servers.
477
478           "URI" objects belonging to the http scheme support the common,
479           generic and server methods.
480
481       https:
482           The https URI scheme is a Netscape invention which is commonly
483           implemented.  The scheme is used to reference HTTP servers through
484           SSL connections.  Its syntax is the same as http, but the default
485           port is different.
486
487       ldap:
488           The ldap URI scheme is specified in RFC 2255.  LDAP is the
489           Lightweight Directory Access Protocol.  An ldap URI describes an
490           LDAP search operation to perform to retrieve information from an
491           LDAP directory.
492
493           "URI" objects belonging to the ldap scheme support the common,
494           generic and server methods as well as ldap-specific methods:
495           $uri->dn, $uri->attributes, $uri->scope, $uri->filter,
496           $uri->extensions.  See URI::ldap for details.
497
498       ldapi:
499           Like the ldap URI scheme, but uses a UNIX domain socket.  The
500           server methods are not supported, and the local socket path is
501           available as $uri->un_path.  The ldapi scheme is used by the
502           OpenLDAP package.  There is no real specification for it, but it is
503           mentioned in various OpenLDAP manual pages.
504
505       ldaps:
506           Like the ldap URI scheme, but uses an SSL connection.  This scheme
507           is deprecated, as the preferred way is to use the start_tls
508           mechanism.
509
510       mailto:
511           The mailto URI scheme is specified in RFC 2368.  The scheme was
512           originally used to designate the Internet mailing address of an
513           individual or service.  It has (in RFC 2368) been extended to allow
514           setting of other mail header fields and the message body.
515
516           "URI" objects belonging to the mailto scheme support the common
517           methods and the generic query methods.  In addition, they support
518           the following mailto-specific methods: $uri->to, $uri->headers.
519
520           Note that the "foo@example.com" part of a mailto is not the
521           "userinfo" and "host" but instead the "path".  This allows a mailto
522           URI to contain multiple comma separated email addresses.
523
524       mms:
525           The mms URL specification can be found at <http://sdp.ppona.com/>.
526           "URI" objects belonging to the mms scheme support the common,
527           generic, and server methods, with the exception of userinfo and
528           query-related sub-components.
529
530       news:
531           The news, nntp and snews URI schemes are specified in
532           <draft-gilman-news-url-01> and will hopefully be available as an
533           RFC 2396 based specification soon. (Update: as of April 2010, they
534           are in RFC 5538 <https://tools.ietf.org/html/rfc5538>.
535
536           "URI" objects belonging to the news scheme support the common,
537           generic and server methods.  In addition, they provide some methods
538           to access the path: $uri->group and $uri->message.
539
540       nntp:
541           See news scheme.
542
543       nntps:
544           See news scheme and RFC 5538 <https://tools.ietf.org/html/rfc5538>.
545
546       pop:
547           The pop URI scheme is specified in RFC 2384. The scheme is used to
548           reference a POP3 mailbox.
549
550           "URI" objects belonging to the pop scheme support the common,
551           generic and server methods.  In addition, they provide two methods
552           to access the userinfo components: $uri->user and $uri->auth
553
554       rlogin:
555           An old specification of the rlogin URI scheme is found in RFC 1738.
556           "URI" objects belonging to the rlogin scheme support the common,
557           generic and server methods.
558
559       rtsp:
560           The rtsp URL specification can be found in section 3.2 of RFC 2326.
561           "URI" objects belonging to the rtsp scheme support the common,
562           generic, and server methods, with the exception of userinfo and
563           query-related sub-components.
564
565       rtspu:
566           The rtspu URI scheme is used to talk to RTSP servers over UDP
567           instead of TCP.  The syntax is the same as rtsp.
568
569       rsync:
570           Information about rsync is available from
571           <http://rsync.samba.org/>.  "URI" objects belonging to the rsync
572           scheme support the common, generic and server methods.  In
573           addition, they provide methods to access the userinfo sub-
574           components: $uri->user and $uri->password.
575
576       sip:
577           The sip URI specification is described in sections 19.1 and 25 of
578           RFC 3261.  "URI" objects belonging to the sip scheme support the
579           common, generic, and server methods with the exception of path
580           related sub-components.  In addition, they provide two methods to
581           get and set sip parameters: $uri->params_form and $uri->params.
582
583       sips:
584           See sip scheme.  Its syntax is the same as sip, but the default
585           port is different.
586
587       snews:
588           See news scheme.  Its syntax is the same as news, but the default
589           port is different.
590
591       telnet:
592           An old specification of the telnet URI scheme is found in RFC 1738.
593           "URI" objects belonging to the telnet scheme support the common,
594           generic and server methods.
595
596       tn3270:
597           These URIs are used like telnet URIs but for connections to IBM
598           mainframes.  "URI" objects belonging to the tn3270 scheme support
599           the common, generic and server methods.
600
601       ssh:
602           Information about ssh is available at <http://www.openssh.com/>.
603           "URI" objects belonging to the ssh scheme support the common,
604           generic and server methods. In addition, they provide methods to
605           access the userinfo sub-components: $uri->user and $uri->password.
606
607       sftp:
608           "URI" objects belonging to the sftp scheme support the common,
609           generic and server methods. In addition, they provide methods to
610           access the userinfo sub-components: $uri->user and $uri->password.
611
612       urn:
613           The syntax of Uniform Resource Names is specified in RFC 2141.
614           "URI" objects belonging to the urn scheme provide the common
615           methods, and also the methods $uri->nid and $uri->nss, which return
616           the Namespace Identifier and the Namespace-Specific String
617           respectively.
618
619           The Namespace Identifier basically works like the Scheme identifier
620           of URIs, and further divides the URN namespace.  Namespace
621           Identifier assignments are maintained at
622           <http://www.iana.org/assignments/urn-namespaces>.
623
624           Letter case is not significant for the Namespace Identifier.  It is
625           always returned in lower case by the $uri->nid method.  The
626           $uri->_nid method can be used if you want it in its original case.
627
628       urn:isbn:
629           The "urn:isbn:" namespace contains International Standard Book
630           Numbers (ISBNs) and is described in RFC 3187.  A "URI" object
631           belonging to this namespace has the following extra methods (if the
632           Business::ISBN module is available): $uri->isbn,
633           $uri->isbn_publisher_code, $uri->isbn_group_code (formerly
634           isbn_country_code, which is still supported by issues a deprecation
635           warning), $uri->isbn_as_ean.
636
637       urn:oid:
638           The "urn:oid:" namespace contains Object Identifiers (OIDs) and is
639           described in RFC 3061.  An object identifier consists of sequences
640           of digits separated by dots.  A "URI" object belonging to this
641           namespace has an additional method called $uri->oid that can be
642           used to get/set the oid value.  In a list context, oid numbers are
643           returned as separate elements.
644

CONFIGURATION VARIABLES

646       The following configuration variables influence how the class and its
647       methods behave:
648
649       $URI::ABS_ALLOW_RELATIVE_SCHEME
650           Some older parsers used to allow the scheme name to be present in
651           the relative URL if it was the same as the base URL scheme.  RFC
652           2396 says that this should be avoided, but you can enable this old
653           behaviour by setting the $URI::ABS_ALLOW_RELATIVE_SCHEME variable
654           to a TRUE value.  The difference is demonstrated by the following
655           examples:
656
657             URI->new("http:foo")->abs("http://host/a/b")
658                 ==>  "http:foo"
659
660             local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
661             URI->new("http:foo")->abs("http://host/a/b")
662                 ==>  "http:/host/a/foo"
663
664       $URI::ABS_REMOTE_LEADING_DOTS
665           You can also have the abs() method ignore excess ".."  segments in
666           the relative URI by setting $URI::ABS_REMOTE_LEADING_DOTS to a TRUE
667           value.  The difference is demonstrated by the following examples:
668
669             URI->new("../../../foo")->abs("http://host/a/b")
670                 ==> "http://host/../../foo"
671
672             local $URI::ABS_REMOTE_LEADING_DOTS = 1;
673             URI->new("../../../foo")->abs("http://host/a/b")
674                 ==> "http://host/foo"
675
676       $URI::DEFAULT_QUERY_FORM_DELIMITER
677           This value can be set to ";" to have the query form "key=value"
678           pairs delimited by ";" instead of "&" which is the default.
679

ENVIRONMENT VARIABLES

681       URI_HAS_RESERVED_SQUARE_BRACKETS
682           Before version 5.11, URI treated square brackets as reserved
683           characters throughout the whole URI string. However, these brackets
684           are reserved only within the authority/host part of the URI and
685           nowhere else (RFC 3986).
686
687           Starting with version 5.11, URI takes this distinction into
688           account.  Setting the environment variable
689           "URI_HAS_RESERVED_SQUARE_BRACKETS" (programmatically or via the
690           shell), restores the old behavior.
691
692             #-- restore 5.10 behavior programmatically
693             BEGIN {
694               $ENV{URI_HAS_RESERVED_SQUARE_BRACKETS} = 1;
695             }
696             use URI ();
697
698           Note: This environment variable is just used during initialization
699           and has to be set
700                 before module URI is used/required. Changing it at run time
701           has no effect.
702
703           Its value can be checked programmatically by accessing the constant
704           "URI::HAS_RESERVED_SQUARE_BRACKETS".
705

BUGS

707       There are some things that are not quite right:
708
709       •   Using regexp variables like $1 directly as arguments to the URI
710           accessor methods does not work too well with current perl
711           implementations.  I would argue that this is actually a bug in
712           perl.  The workaround is to quote them. Example:
713
714              /(...)/ || die;
715              $u->query("$1");
716
717       •   The escaping (percent encoding) of chars in the 128 .. 255 range
718           passed to the URI constructor or when setting URI parts using the
719           accessor methods depend on the state of the internal UTF8 flag (see
720           utf8::is_utf8) of the string passed.  If the UTF8 flag is set the
721           UTF-8 encoded version of the character is percent encoded.  If the
722           UTF8 flag isn't set the Latin-1 version (byte) of the character is
723           percent encoded.  This basically exposes the internal encoding of
724           Perl strings.
725

PARSING URIs WITH REGEXP

727       As an alternative to this module, the following (official) regular
728       expression can be used to decode a URI:
729
730         my($scheme, $authority, $path, $query, $fragment) =
731         $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
732
733       The "URI::Split" module provides the function uri_split() as a readable
734       alternative.
735

SEE ALSO

737       URI::file, URI::WithBase, URI::Escape, URI::Split, URI::Heuristic
738
739       RFC 2396: "Uniform Resource Identifiers (URI): Generic Syntax",
740       Berners-Lee, Fielding, Masinter, August 1998.
741
742       <http://www.iana.org/assignments/uri-schemes>
743
744       <http://www.iana.org/assignments/urn-namespaces>
745
746       <http://www.w3.org/Addressing/>
747
749       Copyright 1995-2009 Gisle Aas.
750
751       Copyright 1995 Martijn Koster.
752
753       This program is free software; you can redistribute it and/or modify it
754       under the same terms as Perl itself.
755

AUTHORS / ACKNOWLEDGMENTS

757       This module is based on the "URI::URL" module, which in turn was
758       (distantly) based on the "wwwurl.pl" code in the libwww-perl for perl4
759       developed by Roy Fielding, as part of the Arcadia project at the
760       University of California, Irvine, with contributions from Brooks
761       Cutter.
762
763       "URI::URL" was developed by Gisle Aas, Tim Bunce, Roy Fielding and
764       Martijn Koster with input from other people on the libwww-perl mailing
765       list.
766
767       "URI" and related subclasses was developed by Gisle Aas.
768
769
770
771perl v5.36.0                      2023-01-20                            URI(3)
Impressum