Perl script. Add license info, fix conditions.