if($licensetext=~ /version ([^ ]+)(?: of the License)?,? or(?: \(at your option\))? version (\d(?:[.-]\d+)*)/){
$gplver=" (v$1 or v$2)";
}elsif($licensetext=~ /version ([^, ]+?)[.,]? (?:\(?only\)?.? )?(?:of the GNU (Affero )?(Lesser |Library )?General Public License )?(as )?published by the Free Software Foundation/ior
$licensetext=~ /GNU (?:Affero )?(?:Lesser |Library )?General Public License (?:as )?published by the Free Software Foundation[;,] version ([^, ]+?)[.,]? /i){
$gplver=" (v$1)";
}elsif($licensetext=~ /GNU (?:Affero )?(?:Lesser |Library )?General Public License\s*(?:[(),GPL]+)\s*version (\d+(?:\.\d+)?)[ \.]/i){
$gplver=" (v$1)";
}elsif($licensetext=~ /either version ([^ ]+)(?: of the License)?, or (?:\(at your option\) )?any later version/){
if($licensetext=~ /As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice/){
if($licensetext=~ /(All changes made in this file will be lost|DO NOT (EDIT|delete this file)|Generated (automatically|by|from)|generated.*file)/i
and$licensetext!~/unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor/){
$license="GENERATED FILE";
}
if($licensetext=~ /(are made available|(is free software.? )?you can redistribute (it|them) and(?:\/|\s+)or modify (it|them)|is licensed) under the terms of (version [^ ]+ of )?the (GNU (Library |Lesser )General Public License|LGPL)/i){
$license="LGPL$gplver$extrainfo $license";
}
# For Perl modules handled by Dist::Zilla
elsif($licensetext=~ /this is free software,? licensed under:? (?:the )?(?:GNU (?:Library |Lesser )General Public License|LGPL),? version ([\d\.]+)/i){
$license="LGPL (v$1) $license";
}
if($licensetext=~ /is free software.? you can redistribute (it|them) and(?:\/|\s+)or modify (it|them) under the terms of the (GNU Affero General Public License|AGPL)/i){
$license="AGPL$gplver$extrainfo $license";
}
if($licensetext=~ /(is free software.? )?you (can|may) redistribute (it|them) and(?:\/|\s+)or modify (it|them) under the terms of (?:version [^ ]+ (?:\(?only\)? )?of )?the GNU General Public License/i){
$license="GPL$gplver$extrainfo $license";
}
if($licensetext=~ /is distributed under the terms of the GNU General Public License,/
}elsif($licensetext=~ /Permission is hereby granted, free of charge, to any person obtaining a copy of this software and(\/or)? associated documentation files \(the (Software|Materials)\), to deal in the (Software|Materials)/){
$license="MIT/X11 (BSD like) $license";
}elsif($licensetext=~ /Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose/){
$license="MIT/X11 (BSD like) $license";
}
if($licensetext=~ /Permission to use, copy, modify, and(\/or)? distribute this software for any purpose with or without fee is hereby granted, provided.*copyright notice.*permission notice.*all copies/){
$license="ISC $license";
}
if($licensetext=~ /THIS SOFTWARE IS PROVIDED .*AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY/){
if($licensetext=~ /All advertising materials mentioning features or use of this software must display the following acknowledge?ment.*This product includes software developed by/i){
$license="BSD (4 clause) $license";
}elsif($licensetext=~ /(The name(?:\(s\))? .*? may not|Neither the (names? .*?|authors?) nor the names of( (its|their|other|any))? contributors may) be used to endorse or promote products derived from this software/i){
$license="BSD (3 clause) $license";
}elsif($licensetext=~ /Redistributions in binary form must reproduce the above copyright notice/i){
$license="BSD (2 clause) $license";
}else{
$license="BSD $license";
}
}
if($licensetext=~ /Mozilla Public License,? (?:(?:Version|v\.)\s+)?(\d+(?:\.\d+)?)/){
$license="MPL (v$1) $license";
}
elsif($licensetext=~ /Mozilla Public License,? \((?:Version|v\.) (\d+(?:\.\d+)?)\)/){
$license="MPL (v$1) $license";
}
# match when either:
# - the text *begins* with "The Artistic license v2.0" which is (hopefully) the actual artistic license v2.0 text.
# - a license grant is found. i.e something like "this is free software, licensed under the artistic license v2.0"
if($licensetext=~ /(?:^\s*|(?:This is free software, licensed|Released|be used|use and modify this (?:module|software)) under (?:the terms of )?)[Tt]he Artistic License ([v\d.]*\d)/){
$license="Artistic (v$1) $license";
}
if($licensetext=~ /is free software under the Artistic [Ll]icense/){
$license="Artistic $license";
}
if($licensetext=~ /This program is free software; you can redistribute it and\/or modify it under the same terms as Perl itself/){
$license="Perl $license";
}
if($licensetext=~ /under the Apache License, Version ([^ ]+)/){
$license="Apache (v$1) $license";
}
if($licensetext=~ /(THE BEER-WARE LICENSE)/i){
$license="Beerware $license";
}
if($licensetext=~ /distributed under the terms of the FreeType project/i){
$license="FreeType $license";# aka FTL see http://www.freetype.org/license.html
}
if($licensetext=~ /This source file is subject to version ([^ ]+) of the PHP license/){
$license="PHP (v$1) $license";
}
if($licensetext=~ /under the terms of the CeCILL /){
$license="CeCILL $license";
}
if($licensetext=~ /under the terms of the CeCILL-([^ ]+) /){
$license="CeCILL-$1 $license";
}
if($licensetext=~ /under the SGI Free Software License B/){
$license="SGI Free Software License B $license";
}
if($licensetext=~ /is in the public domain/i){
$license="Public domain $license";
}
if($licensetext=~ /terms of the Common Development and Distribution License(, Version ([^(]+))? \(the License\)/){
if($licensetext=~ /Licensed under the Academic Free License version ([\d.]+)/){
$license=$1?"AFL-$1":"AFL";
}
if($licensetext=~ /This program and the accompanying materials are made available under the terms of the Eclipse Public License v?([\d.]+)/){
$license=$1?"EPL-$1":"EPL";
}
# quotes were removed by clean_comments function
if($licensetext=~ /Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license \(the Software\)/or
if($licensetext=~ /PYTHON SOFTWARE FOUNDATION LICENSE (VERSION ([^ ]+))/i){
$license="PSF ".($1?"(v$2) ":'').$license;
}
if($licensetext=~ /The origin of this software must not be misrepresented.*Altered source versions must be plainly marked as such.*This notice may not be removed or altered from any source distribution/or
$licensetext=~ /see copyright notice in zlib\.h/){
$license="zlib/libpng $license";
}elsif($licensetext=~ /This code is released under the libpng license/){
$license="libpng $license";
}
if($licensetext=~ /Do What The Fuck You Want To Public License, Version ([^, ]+)/i){
$license="WTFPL (v$1) $license";
}
if($licensetext=~ /Do what The Fuck You Want To Public License/i){