#! perl -wl # Copyright 2012 Ken Takusagawa # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . @a=('A'..'Z','a'..'z','0'..'9',' ','-','_'); for($count=0;$count<1;++$count){ $attempts=0; SEARCH: { $attempts++; $_=""; $length=int(rand 40); $length+=1; for($i=0;$i<$length;++$i){ $_ .= $a[rand@a]; } redo SEARCH if /^[ _-]/ or /[ _-]$/ or /[ _-][ _-]/ or /[A-Z].*[a-z].*[A-Z]/ or /[a-z].*[A-Z].*[a-z]/ or /[0-9].*[A-Za-z].*[0-9]/; redo SEARCH if $exists{$_}; #redo SEARCH unless / /; } $exists{$_}=1; print $_; #,',',$attempts; } #for images, (dsc|img)(_|\d)\d{4}