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           The "URI::QueryParam" module can be loaded to add further methods
299           to manipulate the form of a URI.  See URI::QueryParam for details.
300
301       $uri->query_keywords
302       $uri->query_keywords( $keywords, ... )
303       $uri->query_keywords( \@keywords )
304           Sets and returns query components that use the keywords separated
305           by "+" format.
306
307           The keywords can be set either by passing separate keywords
308           directly or by passing a reference to an array of keywords.
309           Passing an empty array removes the query component, whereas passing
310           no arguments at all leaves the component unchanged.  The old value
311           is always returned as a list of separate words.
312

SERVER METHODS

314       For schemes where the authority component denotes an Internet host, the
315       following methods are available in addition to the generic methods.
316
317       $uri->userinfo
318       $uri->userinfo( $new_userinfo )
319           Sets and returns the escaped userinfo part of the authority
320           component.
321
322           For some schemes this is a user name and a password separated by a
323           colon.  This practice is not recommended. Embedding passwords in
324           clear text (such as URI) has proven to be a security risk in almost
325           every case where it has been used.
326
327       $uri->host
328       $uri->host( $new_host )
329           Sets and returns the unescaped hostname.
330
331           If the $new_host string ends with a colon and a number, then this
332           number also sets the port.
333
334           For IPv6 addresses the brackets around the raw address is removed
335           in the return value from $uri->host.  When setting the host
336           attribute to an IPv6 address you can use a raw address or one
337           enclosed in brackets.  The address needs to be enclosed in brackets
338           if you want to pass in a new port value as well.
339
340       $uri->ihost
341           Returns the host in Unicode form.  Any IDNA A-labels are turned
342           into U-labels.
343
344       $uri->port
345       $uri->port( $new_port )
346           Sets and returns the port.  The port is a simple integer that
347           should be greater than 0.
348
349           If a port is not specified explicitly in the URI, then the URI
350           scheme's default port is returned. If you don't want the default
351           port substituted, then you can use the $uri->_port method instead.
352
353       $uri->host_port
354       $uri->host_port( $new_host_port )
355           Sets and returns the host and port as a single unit.  The returned
356           value includes a port, even if it matches the default port.  The
357           host part and the port part are separated by a colon: ":".
358
359           For IPv6 addresses the bracketing is preserved; thus
360           URI->new("http://[::1]/")->host_port returns "[::1]:80".  Contrast
361           this with $uri->host which will remove the brackets.
362
363       $uri->default_port
364           Returns the default port of the URI scheme to which $uri belongs.
365           For http this is the number 80, for ftp this is the number 21, etc.
366           The default port for a scheme can not be changed.
367

SCHEME-SPECIFIC SUPPORT

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

CONFIGURATION VARIABLES

585       The following configuration variables influence how the class and its
586       methods behave:
587
588       $URI::ABS_ALLOW_RELATIVE_SCHEME
589           Some older parsers used to allow the scheme name to be present in
590           the relative URL if it was the same as the base URL scheme.  RFC
591           2396 says that this should be avoided, but you can enable this old
592           behaviour by setting the $URI::ABS_ALLOW_RELATIVE_SCHEME variable
593           to a TRUE value.  The difference is demonstrated by the following
594           examples:
595
596             URI->new("http:foo")->abs("http://host/a/b")
597                 ==>  "http:foo"
598
599             local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
600             URI->new("http:foo")->abs("http://host/a/b")
601                 ==>  "http:/host/a/foo"
602
603       $URI::ABS_REMOTE_LEADING_DOTS
604           You can also have the abs() method ignore excess ".."  segments in
605           the relative URI by setting $URI::ABS_REMOTE_LEADING_DOTS to a TRUE
606           value.  The difference is demonstrated by the following examples:
607
608             URI->new("../../../foo")->abs("http://host/a/b")
609                 ==> "http://host/../../foo"
610
611             local $URI::ABS_REMOTE_LEADING_DOTS = 1;
612             URI->new("../../../foo")->abs("http://host/a/b")
613                 ==> "http://host/foo"
614
615       $URI::DEFAULT_QUERY_FORM_DELIMITER
616           This value can be set to ";" to have the query form "key=value"
617           pairs delimited by ";" instead of "&" which is the default.
618

BUGS

620       There are some things that are not quite right:
621
622       •   Using regexp variables like $1 directly as arguments to the URI
623           accessor methods does not work too well with current perl
624           implementations.  I would argue that this is actually a bug in
625           perl.  The workaround is to quote them. Example:
626
627              /(...)/ || die;
628              $u->query("$1");
629
630       •   The escaping (percent encoding) of chars in the 128 .. 255 range
631           passed to the URI constructor or when setting URI parts using the
632           accessor methods depend on the state of the internal UTF8 flag (see
633           utf8::is_utf8) of the string passed.  If the UTF8 flag is set the
634           UTF-8 encoded version of the character is percent encoded.  If the
635           UTF8 flag isn't set the Latin-1 version (byte) of the character is
636           percent encoded.  This basically exposes the internal encoding of
637           Perl strings.
638

PARSING URIs WITH REGEXP

640       As an alternative to this module, the following (official) regular
641       expression can be used to decode a URI:
642
643         my($scheme, $authority, $path, $query, $fragment) =
644         $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
645
646       The "URI::Split" module provides the function uri_split() as a readable
647       alternative.
648

SEE ALSO

650       URI::file, URI::WithBase, URI::QueryParam, URI::Escape, URI::Split,
651       URI::Heuristic
652
653       RFC 2396: "Uniform Resource Identifiers (URI): Generic Syntax",
654       Berners-Lee, Fielding, Masinter, August 1998.
655
656       <http://www.iana.org/assignments/uri-schemes>
657
658       <http://www.iana.org/assignments/urn-namespaces>
659
660       <http://www.w3.org/Addressing/>
661
663       Copyright 1995-2009 Gisle Aas.
664
665       Copyright 1995 Martijn Koster.
666
667       This program is free software; you can redistribute it and/or modify it
668       under the same terms as Perl itself.
669

AUTHORS / ACKNOWLEDGMENTS

671       This module is based on the "URI::URL" module, which in turn was
672       (distantly) based on the "wwwurl.pl" code in the libwww-perl for perl4
673       developed by Roy Fielding, as part of the Arcadia project at the
674       University of California, Irvine, with contributions from Brooks
675       Cutter.
676
677       "URI::URL" was developed by Gisle Aas, Tim Bunce, Roy Fielding and
678       Martijn Koster with input from other people on the libwww-perl mailing
679       list.
680
681       "URI" and related subclasses was developed by Gisle Aas.
682
683
684
685perl v5.34.0                      2021-07-23                            URI(3)
Impressum