File Coverage

blib/lib/ParseUtil/Domain.pm
Criterion Covered Total %
statement 146 146 100.0
branch 39 42 92.8
condition 8 9 88.8
subroutine 17 17 100.0
pod 2 2 100.0
total 212 216 98.1


line stmt bran cond sub pod time code
1             package ParseUtil::Domain;
2             $ParseUtil::Domain::VERSION = '2.426';
3             # VERSION
4              
5             require Exporter;
6             our @ISA = qw(Exporter);
7              
8 6     6   1200486 use Modern::Perl;
  6         24278  
  6         44  
9 6     6   2050 use Carp;
  6         11  
  6         394  
10 6     6   4741 use autobox;
  6         42602  
  6         38  
11 6     6   8655 use autobox::Core;
  6         98001  
  6         47  
12 6     6   9499 use List::MoreUtils qw/any/;
  6         49638  
  6         69  
13 6     6   9602 use Net::IDN::Encode ':all';
  6         2700132  
  6         1209  
14 6     6   55 use Net::IDN::Punycode ':all';
  6         12  
  6         605  
15 6     6   4973 use Net::IDN::Nameprep;
  6         933112  
  6         635  
16             #use Smart::Comments;
17              
18 6     6   5515 use ParseUtil::Domain::ConfigData;
  6         27  
  6         12431  
19             our @EXPORT = qw(parse_domain puny_convert);
20             our %EXPORT_TAGS = (parse => [qw/parse_domain/], simple => [qw/puny_convert/]);
21              
22             sub parse_domain {
23 80     80 1 82608 my $name = shift;
24             ### testing : $name
25 80         722 my @name_segments = $name->split(qr{\Q@\E});
26             ### namesegments : \@name_segments
27              
28 80         953 my @segments = $name_segments[-1]->split(qr/[\.\x{FF0E}\x{3002}\x{FF61}]/);
29             ### executing with : $name
30 80         834 my ( $zone, $zone_ace, $domain_segments ) =
31             _find_zone( \@segments )->slice(qw/zone zone_ace domain/);
32              
33             ### found zone : $zone
34             ### found zone_ace : $zone_ace
35              
36 78         962 my $puny_processed = _punycode_segments( $domain_segments, $zone );
37 72         456 my ( $domain_name, $name_ace ) = $puny_processed->slice(qw/name name_ace/);
38             ### puny processed : $puny_processed
39             ### joining name slices : $domain_name
40 72 100       885 $puny_processed->{name} = [ $domain_name, $zone ]->join('.')
41             if $domain_name;
42 72 100       907 $puny_processed->{name_ace} = [ $name_ace, $zone_ace ]->join('.')
43             if $name_ace;
44 72         445 @{$puny_processed}{qw/zone zone_ace/} = ( $zone, $zone_ace );
  72         235  
45              
46             # process .name "email" domains
47 72 100       216 if ( @name_segments > 1 ) {
48 3         14 my $punycoded_name = _punycode_segments( [ $name_segments[0] ], $zone );
49 3         28 my ( $domain, $domain_ace ) =
50             $punycoded_name->slice(qw/domain domain_ace/);
51              
52             $puny_processed->{domain} =
53 3         49 [ $domain, $puny_processed->{domain} ]->join('@');
54 3 50       30 if ($domain_ace) {
55             $puny_processed->{domain_ace} =
56 3         21 [ $domain_ace, $puny_processed->{domain_ace} ]->join('@');
57              
58             }
59             }
60 72         313 return $puny_processed;
61              
62             }
63              
64             sub puny_convert {
65 8     8 1 37698 my $domain = shift;
66 8         14 my @keys;
67 8 100       46 if ( $domain =~ /\.?xn--/ ) {
68 2         7 @keys = qw/domain zone/;
69             }
70             else {
71 6         18 @keys = qw/domain_ace zone_ace/;
72             }
73 8         25 my $parsed = parse_domain($domain);
74 8         38 my $parsed_domain = $parsed->slice(@keys)->join(".");
75              
76 8         153 return $parsed_domain;
77             }
78              
79             sub _find_zone {
80 80     80   132 my $domain_segments = shift;
81              
82 80         346 my $tld_regex = ParseUtil::Domain::ConfigData->tld_regex();
83             ### Domain Segments: $domain_segments
84 80         414 my $tld = $domain_segments->pop;
85 80         507 my $sld = $domain_segments->pop;
86 80         452 my $thld = $domain_segments->pop;
87              
88 80         313 my ( $possible_tld, $possible_thld );
89             my ( $sld_zone_ace, $tld_zone_ace ) =
90 80         143 map { domain_to_ascii( nameprep $_) } $sld, $tld;
  160         56783  
91 80         20131 my $thld_zone_ace;
92 80 100       311 $thld_zone_ace = domain_to_ascii( nameprep $thld) if $thld;
93 80 100       10221 if ( $tld =~ /^de$/ ) {
94             ### is a de domain
95 4         17 $possible_tld = join "." => $tld, _puny_encode($sld);
96             }
97             else {
98 76         181 $possible_tld = join "." => $tld_zone_ace, $sld_zone_ace;
99 76 100       231 $possible_thld = join "." => $possible_tld,
100             $thld_zone_ace
101             if $thld_zone_ace;
102             }
103 80         110 my ( $zone, @zone_params );
104              
105             # first checking for third level domain
106 80 100 100     433473 if ( $possible_thld and $possible_thld =~ /\A$tld_regex\z/ ) {
    100          
    100          
107             ### $possible_thld: $possible_thld
108 10         25 my $zone_ace = join "." => $thld_zone_ace, $sld_zone_ace, $tld_zone_ace;
109 10         23 $zone = join "." => $thld, $sld, $tld;
110 10         22 push @zone_params, zone_ace => $zone_ace;
111             }
112             elsif ( $possible_tld =~ /\A$tld_regex\z/ ) {
113             ### possible_tld: $possible_tld
114 23         75 push @{$domain_segments}, $thld;
  23         102  
115 23         76 my $zone_ace = join "." => $sld_zone_ace, $tld_zone_ace;
116 23         56 $zone = join "." => $sld, $tld;
117 23         64 push @zone_params, zone_ace => $zone_ace;
118             }
119             elsif ( $tld_zone_ace =~ /\A$tld_regex\z/ ) {
120             ### tld_zone_ace: $tld_zone_ace
121 45 100       257 push @{$domain_segments}, $thld if $thld;
  14         42  
122 45         77 push @{$domain_segments}, $sld;
  45         126  
123 45         110 push @zone_params, zone_ace => $tld_zone_ace;
124 45         91 $zone = $tld;
125             }
126 80 100       1026 croak "Could not find tld." unless $zone;
127 78         332 my $unicode_zone = domain_to_unicode($zone);
128             return {
129 78         31930 zone => $unicode_zone,
130             domain => $domain_segments,
131             @zone_params
132             };
133             }
134              
135             sub _punycode_segments {
136 84     84   5313 my ( $domain_segments, $zone ) = @_;
137              
138 84         123 my @name_prefix;
139 84 100 66     471 if ( not $zone or $zone !~ /^(?:de|fr|pm|re|tf|wf|yt)$/ ) {
140 78         156 my $puny_encoded = [];
141 78         113 foreach my $segment ( @{$domain_segments} ) {
  78         183  
142 102 100 100     1466 croak "Error processing domain."
143             . " Please report to package maintainer."
144             if not defined $segment
145             or $segment eq '';
146 96         392 my $nameprepped = nameprep( lc $segment );
147 95         24706 my $ascii = domain_to_ascii($nameprepped);
148 95         3409 push @{$puny_encoded}, $ascii;
  95         327  
149             }
150             my $puny_decoded =
151 71         104 [ map { domain_to_unicode($_) } @{$puny_encoded} ];
  95         737  
  71         139  
152             croak "Undefined mapping!"
153 71 100   95   24339 if any { lc $_ ne nameprep( lc $_ ) } @{$puny_decoded};
  95         4890  
  71         341  
154              
155 70         19211 my $domain = $puny_decoded->join(".");
156 70         577 my $domain_ace = $puny_encoded->join(".");
157              
158 70         440 my $processed_name = _process_name_part($puny_decoded);
159 70         153 my $processed_name_ace = _process_name_part($puny_encoded);
160 70         230 @{$processed_name_ace}{qw/name_ace prefix_ace/} =
161 70         117 delete @{$processed_name_ace}{qw/name prefix/};
  70         203  
162              
163             return {
164             domain => $domain,
165             domain_ace => $domain_ace,
166 70         191 %{$processed_name},
167 70         135 %{$processed_name_ace}
  70         486  
168             };
169             }
170              
171             # Avoid nameprep step for certain tlds
172             my $puny_encoded =
173 6         12 [ map { _puny_encode( lc $_ ) } @{$domain_segments} ];
  6         27  
  6         14  
174 6         14 my $puny_decoded = [ map { _puny_decode($_) } @{$puny_encoded} ];
  6         20  
  6         16  
175 6         50 my $domain = $puny_decoded->join(".");
176 6         56 my $domain_ace = $puny_encoded->join(".");
177 6         46 my $processed_name = _process_name_part($puny_decoded);
178 6         24 my $processed_name_ace = _process_name_part($puny_encoded);
179 6         21 @{$processed_name_ace}{qw/name_ace prefix_ace/} =
180 6         16 delete @{$processed_name_ace}{qw/name prefix/};
  6         21  
181             return {
182             domain => $domain,
183             domain_ace => $domain_ace,
184 6         20 %{$processed_name},
185 6         13 %{$processed_name_ace}
  6         43  
186             };
187              
188             }
189              
190             sub _process_name_part {
191 152     152   236 my $processed = shift;
192 152         183 my @name_prefix;
193 152         577 my $name = $processed->pop;
194 152         997 my $prefix = $processed->join(".");
195 152 100       1001 push @name_prefix, name => $name if $name;
196 152 100       370 push @name_prefix, prefix => $prefix if $prefix;
197 152         570 return {@name_prefix};
198             }
199              
200             sub _puny_encode {
201 10     10   19 my $unencoded = shift;
202              
203             ### encoding : $unencoded
204             # quick check to make sure that domain should be decoded
205 10         38 my $temp_unencoded = nameprep $unencoded;
206             ### namepreped : $temp_unencoded
207 10         4109 my $test_encode = domain_to_ascii($temp_unencoded);
208 10 100       336 return $unencoded if $test_encode eq $unencoded;
209 4         36 return "xn--" . encode_punycode($unencoded);
210             }
211              
212             sub _puny_decode {
213 6     6   16 my $encoded = shift;
214 6 50       39 return $encoded
215             unless $encoded =~ /xn--/;
216 6         27 $encoded =~ s/^xn--//;
217             ### decoding : $encoded
218 6         32 my $test_decode = decode_punycode($encoded);
219             ### test decode : $test_decode
220 6 50       22 return $encoded if $encoded eq $test_decode;
221 6         34 return decode_punycode($encoded);
222              
223             }
224              
225             1;
226              
227             __END__
228              
229             =encoding utf8
230              
231             =head1 NAME
232              
233             ParseUtil::Domain - Domain parser and puny encoder/decoder.
234              
235              
236             =for HTML <a href="https://travis-ci.org/heytrav/ParseUtil-Domain"><img src="https://travis-ci.org/heytrav/ParseUtil-Domain.svg?branch=remove-utf8"></a>
237              
238              
239             =head1 SYNOPSIS
240              
241             use ParseUtil::Domain ':parse';
242              
243             my $processed = parse_domain("somedomain.com");
244             #$processed:
245             #{
246             #domain => 'somedomain',
247             #domain_ace => 'somedomain',
248             #zone => 'com',
249             #zone_ace => 'com'
250             #}
251              
252              
253             =head1 DESCRIPTION
254              
255              
256             This purpose of this module is to parse a domain name into its respective name and tld. Note that
257             the I<tld> may actually refer to a second- or third-level domain, e.g. co.uk or
258             plc.co.im. It also provides respective puny encoded and decoded versions of
259             the parsed domain.
260              
261             This module uses TLD data from the L<Public Suffix List|http://publicsuffix.org/list/> which is included with this
262             distribution.
263              
264              
265             =head1 INTERFACE
266              
267              
268             =head2 parse_domain
269              
270              
271             =over 2
272              
273             =item
274             parse_domain(string)
275              
276              
277             =over 3
278              
279             =item
280             Examples:
281              
282              
283             1. parse_domain('somedomain.com');
284              
285             Result:
286             {
287             domain => 'somedomain',
288             zone => 'com',
289             domain_ace => 'somedomain',
290             zone_ace => 'com'
291             }
292              
293             2. parse_domain('test.xn--o3cw4h');
294              
295             Result:
296             {
297             domain => 'test',
298             zone => 'ไทย',
299             domain_ace => 'test',
300             zone_ace => 'xn--o3cw4h'
301             }
302              
303             3. parse_domain('bloß.co.at');
304              
305             Result:
306             {
307             domain => 'bloss',
308             zone => 'co.at',
309             domain_ace => 'bloss',
310             zone_ace => 'co.at'
311             }
312              
313             4. parse_domain('bloß.de');
314              
315             Result:
316             {
317             domain => 'bloß',
318             zone => 'de',
319             domain_ace => 'xn--blo-7ka',
320             zone_ace => 'de'
321             }
322              
323             5. parse_domain('www.whatever.com');
324              
325             Result:
326             {
327             domain => 'www.whatever',
328             zone => 'com',
329             domain_ace => 'www.whatever',
330             zone_ace => 'com',
331             name => 'whatever',
332             name_ace => 'whatever',
333             prefix => 'www',
334             prefix_ace => 'www'
335             }
336              
337             =back
338              
339              
340              
341             =back
342              
343             =head2 puny_convert
344              
345             Toggles a domain between puny encoded and decoded versions.
346              
347              
348             use ParseUtil::Domain ':simple';
349              
350             my $result = puny_convert('bloß.de');
351             # $result: xn--blo-7ka.de
352              
353             my $reverse = puny_convert('xn--blo-7ka.de');
354             # $reverse: bloß.de
355              
356              
357              
358              
359              
360              
361             =head1 DEPENDENCIES
362              
363             =over 3
364              
365              
366             =item
367             L<Net::IDN::Encode>
368              
369              
370             =item
371             L<Net::IDN::Punycode>
372              
373              
374             =item
375             L<Regexp::Assemble::Compressed>
376              
377              
378             =item
379             The L<Public Suffix List|http://publicsuffix.org/list/>.
380              
381              
382             =back
383              
384              
385             =head1 CHANGES
386              
387              
388             =over 3
389              
390              
391             =item *
392             Added extra I<prefix> and I<name> fields to output to separate the actual registered part of the domain from subdomains (or things like I<www>).
393              
394             =item *
395             Updated with latest version of the public suffix list.
396              
397             =item *
398             Added a bunch of new TLDs (nTLDs).
399              
400              
401              
402             =back
403              
404             =head1 LICENSE
405              
406             This software is copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
407              
408             This is free software; you can redistribute it and/or modify it under
409             the same terms as the Perl 5 programming language system itself.
410              
411             Terms of the Perl programming language system itself
412              
413             a) the GNU General Public License as published by the Free
414             Software Foundation; either version 1, or (at your option) any
415             later version, or
416             b) the "Artistic License"
417              
418             --- The GNU General Public License, Version 1, February 1989 ---
419              
420             This software is Copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
421              
422             This is free software, licensed under:
423              
424             The GNU General Public License, Version 1, February 1989
425              
426             GNU GENERAL PUBLIC LICENSE
427             Version 1, February 1989
428              
429             Copyright (C) 1989 Free Software Foundation, Inc.
430             51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
431              
432             Everyone is permitted to copy and distribute verbatim copies
433             of this license document, but changing it is not allowed.
434              
435             Preamble
436              
437             The license agreements of most software companies try to keep users
438             at the mercy of those companies. By contrast, our General Public
439             License is intended to guarantee your freedom to share and change free
440             software--to make sure the software is free for all its users. The
441             General Public License applies to the Free Software Foundation's
442             software and to any other program whose authors commit to using it.
443             You can use it for your programs, too.
444              
445             When we speak of free software, we are referring to freedom, not
446             price. Specifically, the General Public License is designed to make
447             sure that you have the freedom to give away or sell copies of free
448             software, that you receive source code or can get it if you want it,
449             that you can change the software or use pieces of it in new free
450             programs; and that you know you can do these things.
451              
452             To protect your rights, we need to make restrictions that forbid
453             anyone to deny you these rights or to ask you to surrender the rights.
454             These restrictions translate to certain responsibilities for you if you
455             distribute copies of the software, or if you modify it.
456              
457             For example, if you distribute copies of a such a program, whether
458             gratis or for a fee, you must give the recipients all the rights that
459             you have. You must make sure that they, too, receive or can get the
460             source code. And you must tell them their rights.
461              
462             We protect your rights with two steps: (1) copyright the software, and
463             (2) offer you this license which gives you legal permission to copy,
464             distribute and/or modify the software.
465              
466             Also, for each author's protection and ours, we want to make certain
467             that everyone understands that there is no warranty for this free
468             software. If the software is modified by someone else and passed on, we
469             want its recipients to know that what they have is not the original, so
470             that any problems introduced by others will not reflect on the original
471             authors' reputations.
472              
473             The precise terms and conditions for copying, distribution and
474             modification follow.
475              
476             GNU GENERAL PUBLIC LICENSE
477             TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
478              
479             0. This License Agreement applies to any program or other work which
480             contains a notice placed by the copyright holder saying it may be
481             distributed under the terms of this General Public License. The
482             "Program", below, refers to any such program or work, and a "work based
483             on the Program" means either the Program or any work containing the
484             Program or a portion of it, either verbatim or with modifications. Each
485             licensee is addressed as "you".
486              
487             1. You may copy and distribute verbatim copies of the Program's source
488             code as you receive it, in any medium, provided that you conspicuously and
489             appropriately publish on each copy an appropriate copyright notice and
490             disclaimer of warranty; keep intact all the notices that refer to this
491             General Public License and to the absence of any warranty; and give any
492             other recipients of the Program a copy of this General Public License
493             along with the Program. You may charge a fee for the physical act of
494             transferring a copy.
495              
496             2. You may modify your copy or copies of the Program or any portion of
497             it, and copy and distribute such modifications under the terms of Paragraph
498             1 above, provided that you also do the following:
499              
500             a) cause the modified files to carry prominent notices stating that
501             you changed the files and the date of any change; and
502              
503             b) cause the whole of any work that you distribute or publish, that
504             in whole or in part contains the Program or any part thereof, either
505             with or without modifications, to be licensed at no charge to all
506             third parties under the terms of this General Public License (except
507             that you may choose to grant warranty protection to some or all
508             third parties, at your option).
509              
510             c) If the modified program normally reads commands interactively when
511             run, you must cause it, when started running for such interactive use
512             in the simplest and most usual way, to print or display an
513             announcement including an appropriate copyright notice and a notice
514             that there is no warranty (or else, saying that you provide a
515             warranty) and that users may redistribute the program under these
516             conditions, and telling the user how to view a copy of this General
517             Public License.
518              
519             d) You may charge a fee for the physical act of transferring a
520             copy, and you may at your option offer warranty protection in
521             exchange for a fee.
522              
523             Mere aggregation of another independent work with the Program (or its
524             derivative) on a volume of a storage or distribution medium does not bring
525             the other work under the scope of these terms.
526              
527             3. You may copy and distribute the Program (or a portion or derivative of
528             it, under Paragraph 2) in object code or executable form under the terms of
529             Paragraphs 1 and 2 above provided that you also do one of the following:
530              
531             a) accompany it with the complete corresponding machine-readable
532             source code, which must be distributed under the terms of
533             Paragraphs 1 and 2 above; or,
534              
535             b) accompany it with a written offer, valid for at least three
536             years, to give any third party free (except for a nominal charge
537             for the cost of distribution) a complete machine-readable copy of the
538             corresponding source code, to be distributed under the terms of
539             Paragraphs 1 and 2 above; or,
540              
541             c) accompany it with the information you received as to where the
542             corresponding source code may be obtained. (This alternative is
543             allowed only for noncommercial distribution and only if you
544             received the program in object code or executable form alone.)
545              
546             Source code for a work means the preferred form of the work for making
547             modifications to it. For an executable file, complete source code means
548             all the source code for all modules it contains; but, as a special
549             exception, it need not include source code for modules which are standard
550             libraries that accompany the operating system on which the executable
551             file runs, or for standard header files or definitions files that
552             accompany that operating system.
553              
554             4. You may not copy, modify, sublicense, distribute or transfer the
555             Program except as expressly provided under this General Public License.
556             Any attempt otherwise to copy, modify, sublicense, distribute or transfer
557             the Program is void, and will automatically terminate your rights to use
558             the Program under this License. However, parties who have received
559             copies, or rights to use copies, from you under this General Public
560             License will not have their licenses terminated so long as such parties
561             remain in full compliance.
562              
563             5. By copying, distributing or modifying the Program (or any work based
564             on the Program) you indicate your acceptance of this license to do so,
565             and all its terms and conditions.
566              
567             6. Each time you redistribute the Program (or any work based on the
568             Program), the recipient automatically receives a license from the original
569             licensor to copy, distribute or modify the Program subject to these
570             terms and conditions. You may not impose any further restrictions on the
571             recipients' exercise of the rights granted herein.
572              
573             7. The Free Software Foundation may publish revised and/or new versions
574             of the General Public License from time to time. Such new versions will
575             be similar in spirit to the present version, but may differ in detail to
576             address new problems or concerns.
577              
578             Each version is given a distinguishing version number. If the Program
579             specifies a version number of the license which applies to it and "any
580             later version", you have the option of following the terms and conditions
581             either of that version or of any later version published by the Free
582             Software Foundation. If the Program does not specify a version number of
583             the license, you may choose any version ever published by the Free Software
584             Foundation.
585              
586             8. If you wish to incorporate parts of the Program into other free
587             programs whose distribution conditions are different, write to the author
588             to ask for permission. For software which is copyrighted by the Free
589             Software Foundation, write to the Free Software Foundation; we sometimes
590             make exceptions for this. Our decision will be guided by the two goals
591             of preserving the free status of all derivatives of our free software and
592             of promoting the sharing and reuse of software generally.
593              
594             NO WARRANTY
595              
596             9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
597             FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
598             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
599             PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
600             OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
601             MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
602             TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
603             PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
604             REPAIR OR CORRECTION.
605              
606             10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
607             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
608             REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
609             INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
610             OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
611             TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
612             YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
613             PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
614             POSSIBILITY OF SUCH DAMAGES.
615              
616             END OF TERMS AND CONDITIONS
617              
618             Appendix: How to Apply These Terms to Your New Programs
619              
620             If you develop a new program, and you want it to be of the greatest
621             possible use to humanity, the best way to achieve this is to make it
622             free software which everyone can redistribute and change under these
623             terms.
624              
625             To do so, attach the following notices to the program. It is safest to
626             attach them to the start of each source file to most effectively convey
627             the exclusion of warranty; and each file should have at least the
628             "copyright" line and a pointer to where the full notice is found.
629              
630             <one line to give the program's name and a brief idea of what it does.>
631             Copyright (C) 19yy <name of author>
632              
633             This program is free software; you can redistribute it and/or modify
634             it under the terms of the GNU General Public License as published by
635             the Free Software Foundation; either version 1, or (at your option)
636             any later version.
637              
638             This program is distributed in the hope that it will be useful,
639             but WITHOUT ANY WARRANTY; without even the implied warranty of
640             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
641             GNU General Public License for more details.
642              
643             You should have received a copy of the GNU General Public License
644             along with this program; if not, write to the Free Software
645             Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
646              
647              
648             Also add information on how to contact you by electronic and paper mail.
649              
650             If the program is interactive, make it output a short notice like this
651             when it starts in an interactive mode:
652              
653             Gnomovision version 69, Copyright (C) 19xx name of author
654             Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
655             This is free software, and you are welcome to redistribute it
656             under certain conditions; type `show c' for details.
657              
658             The hypothetical commands `show w' and `show c' should show the
659             appropriate parts of the General Public License. Of course, the
660             commands you use may be called something other than `show w' and `show
661             c'; they could even be mouse-clicks or menu items--whatever suits your
662             program.
663              
664             You should also get your employer (if you work as a programmer) or your
665             school, if any, to sign a "copyright disclaimer" for the program, if
666             necessary. Here a sample; alter the names:
667              
668             Yoyodyne, Inc., hereby disclaims all copyright interest in the
669             program `Gnomovision' (a program to direct compilers to make passes
670             at assemblers) written by James Hacker.
671              
672             <signature of Ty Coon>, 1 April 1989
673             Ty Coon, President of Vice
674              
675             That's all there is to it!
676              
677              
678             --- The Artistic License 1.0 ---
679              
680             This software is Copyright (c) 2014 by Trav Holton <heytrav@cpan.org>.
681              
682             This is free software, licensed under:
683              
684             The Artistic License 1.0
685              
686             The Artistic License
687              
688             Preamble
689              
690             The intent of this document is to state the conditions under which a Package
691             may be copied, such that the Copyright Holder maintains some semblance of
692             artistic control over the development of the package, while giving the users of
693             the package the right to use and distribute the Package in a more-or-less
694             customary fashion, plus the right to make reasonable modifications.
695              
696             Definitions:
697              
698             - "Package" refers to the collection of files distributed by the Copyright
699             Holder, and derivatives of that collection of files created through
700             textual modification.
701             - "Standard Version" refers to such a Package if it has not been modified,
702             or has been modified in accordance with the wishes of the Copyright
703             Holder.
704             - "Copyright Holder" is whoever is named in the copyright or copyrights for
705             the package.
706             - "You" is you, if you're thinking about copying or distributing this Package.
707             - "Reasonable copying fee" is whatever you can justify on the basis of media
708             cost, duplication charges, time of people involved, and so on. (You will
709             not be required to justify it to the Copyright Holder, but only to the
710             computing community at large as a market that must bear the fee.)
711             - "Freely Available" means that no fee is charged for the item itself, though
712             there may be fees involved in handling the item. It also means that
713             recipients of the item may redistribute it under the same conditions they
714             received it.
715              
716             1. You may make and give away verbatim copies of the source form of the
717             Standard Version of this Package without restriction, provided that you
718             duplicate all of the original copyright notices and associated disclaimers.
719              
720             2. You may apply bug fixes, portability fixes and other modifications derived
721             from the Public Domain or from the Copyright Holder. A Package modified in such
722             a way shall still be considered the Standard Version.
723              
724             3. You may otherwise modify your copy of this Package in any way, provided that
725             you insert a prominent notice in each changed file stating how and when you
726             changed that file, and provided that you do at least ONE of the following:
727              
728             a) place your modifications in the Public Domain or otherwise make them
729             Freely Available, such as by posting said modifications to Usenet or an
730             equivalent medium, or placing the modifications on a major archive site
731             such as ftp.uu.net, or by allowing the Copyright Holder to include your
732             modifications in the Standard Version of the Package.
733              
734             b) use the modified Package only within your corporation or organization.
735              
736             c) rename any non-standard executables so the names do not conflict with
737             standard executables, which must also be provided, and provide a separate
738             manual page for each non-standard executable that clearly documents how it
739             differs from the Standard Version.
740              
741             d) make other distribution arrangements with the Copyright Holder.
742              
743             4. You may distribute the programs of this Package in object code or executable
744             form, provided that you do at least ONE of the following:
745              
746             a) distribute a Standard Version of the executables and library files,
747             together with instructions (in the manual page or equivalent) on where to
748             get the Standard Version.
749              
750             b) accompany the distribution with the machine-readable source of the Package
751             with your modifications.
752              
753             c) accompany any non-standard executables with their corresponding Standard
754             Version executables, giving the non-standard executables non-standard
755             names, and clearly documenting the differences in manual pages (or
756             equivalent), together with instructions on where to get the Standard
757             Version.
758              
759             d) make other distribution arrangements with the Copyright Holder.
760              
761             5. You may charge a reasonable copying fee for any distribution of this
762             Package. You may charge any fee you choose for support of this Package. You
763             may not charge a fee for this Package itself. However, you may distribute this
764             Package in aggregate with other (possibly commercial) programs as part of a
765             larger (possibly commercial) software distribution provided that you do not
766             advertise this Package as a product of your own.
767              
768             6. The scripts and library files supplied as input to or produced as output
769             from the programs of this Package do not automatically fall under the copyright
770             of this Package, but belong to whomever generated them, and may be sold
771             commercially, and may be aggregated with this Package.
772              
773             7. C or perl subroutines supplied by you and linked into this Package shall not
774             be considered part of this Package.
775              
776             8. The name of the Copyright Holder may not be used to endorse or promote
777             products derived from this software without specific prior written permission.
778              
779             9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
780             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
781             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
782              
783             The End
784