1ParseUtil::Domain(3) User Contributed Perl Documentation ParseUtil::Domain(3)
2
3
4
6 ParseUtil::Domain - Domain parser and puny encoder/decoder.
7
9 use ParseUtil::Domain ':parse';
10
11 my $processed = parse_domain("somedomain.com");
12 #$processed:
13 #{
14 #domain => 'somedomain',
15 #domain_ace => 'somedomain',
16 #zone => 'com',
17 #zone_ace => 'com'
18 #}
19
21 This purpose of this module is to parse a domain name into its
22 respective name and tld. Note that the tld may actually refer to a
23 second- or third-level domain, e.g. co.uk or plc.co.im. It also
24 provides respective puny encoded and decoded versions of the parsed
25 domain.
26
27 This module uses TLD data from the Public Suffix List
28 <http://publicsuffix.org/list/> which is included with this
29 distribution.
30
32 parse_domain
33 parse_domain(string)
34 Examples:
35 1. parse_domain('somedomain.com');
36
37 Result:
38 {
39 domain => 'somedomain',
40 zone => 'com',
41 domain_ace => 'somedomain',
42 zone_ace => 'com'
43 }
44
45 2. parse_domain('test.xn--o3cw4h');
46
47 Result:
48 {
49 domain => 'test',
50 zone => 'ไทย',
51 domain_ace => 'test',
52 zone_ace => 'xn--o3cw4h'
53 }
54
55 3. parse_domain('bloß.co.at');
56
57 Result:
58 {
59 domain => 'bloss',
60 zone => 'co.at',
61 domain_ace => 'bloss',
62 zone_ace => 'co.at'
63 }
64
65 4. parse_domain('bloß.de');
66
67 Result:
68 {
69 domain => 'bloß',
70 zone => 'de',
71 domain_ace => 'xn--blo-7ka',
72 zone_ace => 'de'
73 }
74
75 5. parse_domain('www.whatever.com');
76
77 Result:
78 {
79 domain => 'www.whatever',
80 zone => 'com',
81 domain_ace => 'www.whatever',
82 zone_ace => 'com',
83 name => 'whatever',
84 name_ace => 'whatever',
85 prefix => 'www',
86 prefix_ace => 'www'
87 }
88
89 puny_convert
90 Toggles a domain between puny encoded and decoded versions.
91
92 use ParseUtil::Domain ':simple';
93
94 my $result = puny_convert('bloß.de');
95 # $result: xn--blo-7ka.de
96
97 my $reverse = puny_convert('xn--blo-7ka.de');
98 # $reverse: bloß.de
99
101 Net::IDN::Encode
102 Net::IDN::Punycode
103 Regexp::Assemble::Compressed
104 The Public Suffix List <http://publicsuffix.org/list/>.
105
107 · Added extra prefix and name fields to output to separate the actual
108 registered part of the domain from subdomains (or things like www).
109
110 · Updated with latest version of the public suffix list.
111
112 · Added a bunch of new TLDs (nTLDs).
113
115 This software is copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
116
117 This is free software; you can redistribute it and/or modify it under
118 the same terms as the Perl 5 programming language system itself.
119
120 Terms of the Perl programming language system itself
121
122 a) the GNU General Public License as published by the Free
123 Software Foundation; either version 1, or (at your option) any
124 later version, or b) the "Artistic License"
125
126 --- The GNU General Public License, Version 1, February 1989 ---
127
128 This software is Copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
129
130 This is free software, licensed under:
131
132 The GNU General Public License, Version 1, February 1989
133
134 GNU GENERAL PUBLIC LICENSE
135 Version 1, February 1989
136
137 Copyright (C) 1989 Free Software Foundation, Inc.
138 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
139
140 Everyone is permitted to copy and distribute verbatim copies
141 of this license document, but changing it is not allowed.
142
143 Preamble
144
145 The license agreements of most software companies try to keep users
146 at the mercy of those companies. By contrast, our General Public
147 License is intended to guarantee your freedom to share and change free
148 software--to make sure the software is free for all its users. The
149 General Public License applies to the Free Software Foundation's
150 software and to any other program whose authors commit to using it.
151 You can use it for your programs, too.
152
153 When we speak of free software, we are referring to freedom, not
154 price. Specifically, the General Public License is designed to make
155 sure that you have the freedom to give away or sell copies of free
156 software, that you receive source code or can get it if you want it,
157 that you can change the software or use pieces of it in new free
158 programs; and that you know you can do these things.
159
160 To protect your rights, we need to make restrictions that forbid
161 anyone to deny you these rights or to ask you to surrender the rights.
162 These restrictions translate to certain responsibilities for you if you
163 distribute copies of the software, or if you modify it.
164
165 For example, if you distribute copies of a such a program, whether
166 gratis or for a fee, you must give the recipients all the rights that
167 you have. You must make sure that they, too, receive or can get the
168 source code. And you must tell them their rights.
169
170 We protect your rights with two steps: (1) copyright the software, and
171 (2) offer you this license which gives you legal permission to copy,
172 distribute and/or modify the software.
173
174 Also, for each author's protection and ours, we want to make certain
175 that everyone understands that there is no warranty for this free
176 software. If the software is modified by someone else and passed on, we
177 want its recipients to know that what they have is not the original, so
178 that any problems introduced by others will not reflect on the original
179 authors' reputations.
180
181 The precise terms and conditions for copying, distribution and
182 modification follow.
183
184 GNU GENERAL PUBLIC LICENSE
185 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
186
187 0. This License Agreement applies to any program or other work which
188 contains a notice placed by the copyright holder saying it may be
189 distributed under the terms of this General Public License. The
190 "Program", below, refers to any such program or work, and a "work based
191 on the Program" means either the Program or any work containing the
192 Program or a portion of it, either verbatim or with modifications. Each
193 licensee is addressed as "you".
194
195 1. You may copy and distribute verbatim copies of the Program's source
196 code as you receive it, in any medium, provided that you conspicuously and
197 appropriately publish on each copy an appropriate copyright notice and
198 disclaimer of warranty; keep intact all the notices that refer to this
199 General Public License and to the absence of any warranty; and give any
200 other recipients of the Program a copy of this General Public License
201 along with the Program. You may charge a fee for the physical act of
202 transferring a copy.
203
204 2. You may modify your copy or copies of the Program or any portion of
205 it, and copy and distribute such modifications under the terms of Paragraph
206 1 above, provided that you also do the following:
207
208 a) cause the modified files to carry prominent notices stating that
209 you changed the files and the date of any change; and
210
211 b) cause the whole of any work that you distribute or publish, that
212 in whole or in part contains the Program or any part thereof, either
213 with or without modifications, to be licensed at no charge to all
214 third parties under the terms of this General Public License (except
215 that you may choose to grant warranty protection to some or all
216 third parties, at your option).
217
218 c) If the modified program normally reads commands interactively when
219 run, you must cause it, when started running for such interactive use
220 in the simplest and most usual way, to print or display an
221 announcement including an appropriate copyright notice and a notice
222 that there is no warranty (or else, saying that you provide a
223 warranty) and that users may redistribute the program under these
224 conditions, and telling the user how to view a copy of this General
225 Public License.
226
227 d) You may charge a fee for the physical act of transferring a
228 copy, and you may at your option offer warranty protection in
229 exchange for a fee.
230
231 Mere aggregation of another independent work with the Program (or its
232 derivative) on a volume of a storage or distribution medium does not
233 bring the other work under the scope of these terms.
234
235 3. You may copy and distribute the Program (or a portion or derivative of
236 it, under Paragraph 2) in object code or executable form under the terms of
237 Paragraphs 1 and 2 above provided that you also do one of the following:
238
239 a) accompany it with the complete corresponding machine-readable
240 source code, which must be distributed under the terms of
241 Paragraphs 1 and 2 above; or,
242
243 b) accompany it with a written offer, valid for at least three
244 years, to give any third party free (except for a nominal charge
245 for the cost of distribution) a complete machine-readable copy of the
246 corresponding source code, to be distributed under the terms of
247 Paragraphs 1 and 2 above; or,
248
249 c) accompany it with the information you received as to where the
250 corresponding source code may be obtained. (This alternative is
251 allowed only for noncommercial distribution and only if you
252 received the program in object code or executable form alone.)
253
254 Source code for a work means the preferred form of the work for making
255 modifications to it. For an executable file, complete source code
256 means all the source code for all modules it contains; but, as a
257 special exception, it need not include source code for modules which
258 are standard libraries that accompany the operating system on which the
259 executable file runs, or for standard header files or definitions files
260 that accompany that operating system.
261
262 4. You may not copy, modify, sublicense, distribute or transfer the
263 Program except as expressly provided under this General Public License.
264 Any attempt otherwise to copy, modify, sublicense, distribute or transfer
265 the Program is void, and will automatically terminate your rights to use
266 the Program under this License. However, parties who have received
267 copies, or rights to use copies, from you under this General Public
268 License will not have their licenses terminated so long as such parties
269 remain in full compliance.
270
271 5. By copying, distributing or modifying the Program (or any work based
272 on the Program) you indicate your acceptance of this license to do so,
273 and all its terms and conditions.
274
275 6. Each time you redistribute the Program (or any work based on the
276 Program), the recipient automatically receives a license from the original
277 licensor to copy, distribute or modify the Program subject to these
278 terms and conditions. You may not impose any further restrictions on the
279 recipients' exercise of the rights granted herein.
280
281 7. The Free Software Foundation may publish revised and/or new versions
282 of the General Public License from time to time. Such new versions will
283 be similar in spirit to the present version, but may differ in detail to
284 address new problems or concerns.
285
286 Each version is given a distinguishing version number. If the Program
287 specifies a version number of the license which applies to it and "any
288 later version", you have the option of following the terms and
289 conditions either of that version or of any later version published by
290 the Free Software Foundation. If the Program does not specify a
291 version number of the license, you may choose any version ever
292 published by the Free Software Foundation.
293
294 8. If you wish to incorporate parts of the Program into other free
295 programs whose distribution conditions are different, write to the author
296 to ask for permission. For software which is copyrighted by the Free
297 Software Foundation, write to the Free Software Foundation; we sometimes
298 make exceptions for this. Our decision will be guided by the two goals
299 of preserving the free status of all derivatives of our free software and
300 of promoting the sharing and reuse of software generally.
301
302 NO WARRANTY
303
304 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
305 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
306 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
307 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
308 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
309 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
310 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
311 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
312 REPAIR OR CORRECTION.
313
314 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
315 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
316 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
317 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
318 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
319 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
320 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
321 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
322 POSSIBILITY OF SUCH DAMAGES.
323
324 END OF TERMS AND CONDITIONS
325
326 Appendix: How to Apply These Terms to Your New Programs
327
328 If you develop a new program, and you want it to be of the greatest
329 possible use to humanity, the best way to achieve this is to make it
330 free software which everyone can redistribute and change under these
331 terms.
332
333 To do so, attach the following notices to the program. It is safest to
334 attach them to the start of each source file to most effectively convey
335 the exclusion of warranty; and each file should have at least the
336 "copyright" line and a pointer to where the full notice is found.
337
338 <one line to give the program's name and a brief idea of what it does.>
339 Copyright (C) 19yy <name of author>
340
341 This program is free software; you can redistribute it and/or modify
342 it under the terms of the GNU General Public License as published by
343 the Free Software Foundation; either version 1, or (at your option)
344 any later version.
345
346 This program is distributed in the hope that it will be useful,
347 but WITHOUT ANY WARRANTY; without even the implied warranty of
348 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
349 GNU General Public License for more details.
350
351 You should have received a copy of the GNU General Public License
352 along with this program; if not, write to the Free Software
353 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
354
355 Also add information on how to contact you by electronic and paper
356 mail.
357
358 If the program is interactive, make it output a short notice like this
359 when it starts in an interactive mode:
360
361 Gnomovision version 69, Copyright (C) 19xx name of author
362 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
363 This is free software, and you are welcome to redistribute it
364 under certain conditions; type `show c' for details.
365
366 The hypothetical commands `show w' and `show c' should show the
367 appropriate parts of the General Public License. Of course, the
368 commands you use may be called something other than `show w' and `show
369 c'; they could even be mouse-clicks or menu items--whatever suits your
370 program.
371
372 You should also get your employer (if you work as a programmer) or your
373 school, if any, to sign a "copyright disclaimer" for the program, if
374 necessary. Here a sample; alter the names:
375
376 Yoyodyne, Inc., hereby disclaims all copyright interest in the
377 program `Gnomovision' (a program to direct compilers to make passes
378 at assemblers) written by James Hacker.
379
380 <signature of Ty Coon>, 1 April 1989
381 Ty Coon, President of Vice
382
383 That's all there is to it!
384
385 --- The Artistic License 1.0 ---
386
387 This software is Copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
388
389 This is free software, licensed under:
390
391 The Artistic License 1.0
392
393 The Artistic License
394
395 Preamble
396
397 The intent of this document is to state the conditions under which a
398 Package may be copied, such that the Copyright Holder maintains some
399 semblance of artistic control over the development of the package,
400 while giving the users of the package the right to use and distribute
401 the Package in a more-or-less customary fashion, plus the right to make
402 reasonable modifications.
403
404 Definitions:
405
406 - "Package" refers to the collection of files distributed by the Copyright
407 Holder, and derivatives of that collection of files created through
408 textual modification.
409 - "Standard Version" refers to such a Package if it has not been modified,
410 or has been modified in accordance with the wishes of the Copyright
411 Holder.
412 - "Copyright Holder" is whoever is named in the copyright or copyrights for
413 the package.
414 - "You" is you, if you're thinking about copying or distributing this Package.
415 - "Reasonable copying fee" is whatever you can justify on the basis of media
416 cost, duplication charges, time of people involved, and so on. (You will
417 not be required to justify it to the Copyright Holder, but only to the
418 computing community at large as a market that must bear the fee.)
419 - "Freely Available" means that no fee is charged for the item itself, though
420 there may be fees involved in handling the item. It also means that
421 recipients of the item may redistribute it under the same conditions they
422 received it.
423
424 1. You may make and give away verbatim copies of the source form of the
425 Standard Version of this Package without restriction, provided that you
426 duplicate all of the original copyright notices and associated
427 disclaimers.
428
429 2. You may apply bug fixes, portability fixes and other modifications
430 derived from the Public Domain or from the Copyright Holder. A Package
431 modified in such a way shall still be considered the Standard Version.
432
433 3. You may otherwise modify your copy of this Package in any way,
434 provided that you insert a prominent notice in each changed file
435 stating how and when you changed that file, and provided that you do at
436 least ONE of the following:
437
438 a) place your modifications in the Public Domain or otherwise make them
439 Freely Available, such as by posting said modifications to Usenet or an
440 equivalent medium, or placing the modifications on a major archive site
441 such as ftp.uu.net, or by allowing the Copyright Holder to include your
442 modifications in the Standard Version of the Package.
443
444 b) use the modified Package only within your corporation or organization.
445
446 c) rename any non-standard executables so the names do not conflict with
447 standard executables, which must also be provided, and provide a separate
448 manual page for each non-standard executable that clearly documents how it
449 differs from the Standard Version.
450
451 d) make other distribution arrangements with the Copyright Holder.
452
453 4. You may distribute the programs of this Package in object code or
454 executable form, provided that you do at least ONE of the following:
455
456 a) distribute a Standard Version of the executables and library files,
457 together with instructions (in the manual page or equivalent) on where to
458 get the Standard Version.
459
460 b) accompany the distribution with the machine-readable source of the Package
461 with your modifications.
462
463 c) accompany any non-standard executables with their corresponding Standard
464 Version executables, giving the non-standard executables non-standard
465 names, and clearly documenting the differences in manual pages (or
466 equivalent), together with instructions on where to get the Standard
467 Version.
468
469 d) make other distribution arrangements with the Copyright Holder.
470
471 5. You may charge a reasonable copying fee for any distribution of this
472 Package. You may charge any fee you choose for support of this
473 Package. You may not charge a fee for this Package itself. However, you
474 may distribute this Package in aggregate with other (possibly
475 commercial) programs as part of a larger (possibly commercial) software
476 distribution provided that you do not advertise this Package as a
477 product of your own.
478
479 6. The scripts and library files supplied as input to or produced as
480 output from the programs of this Package do not automatically fall
481 under the copyright of this Package, but belong to whomever generated
482 them, and may be sold commercially, and may be aggregated with this
483 Package.
484
485 7. C or perl subroutines supplied by you and linked into this Package
486 shall not be considered part of this Package.
487
488 8. The name of the Copyright Holder may not be used to endorse or
489 promote products derived from this software without specific prior
490 written permission.
491
492 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
493 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
494 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
495
496 The End
497
498
499
500perl v5.32.0 2020-07-28 ParseUtil::Domain(3)