$cities = "cities.txt"; # number/letters - city correspondences $cities_st = "cities_st.txt"; # city standard file $tmp = "temp.txt"; # temp file to keep the password # choose random letters or numbers @array = (0..9,a..z,A..Z); srand; foreach (1..5) { $rand = int(rand scalar(@array)); push (@selected, $rand); } # save the chosen password to file open TMP, ">$tmp"; print TMP @selected; close TMP; # open file with number/letter - cities correspondences open CITIES, $cities; while () { for ($x; $x<5; $x++) { $match = $selected[$x]; if (/\+$match\+(\w+)/) {$selected[$x] = $1;} } } close CITIES; # erase file with number/letter - city correspondences unlink $cities; # read "cities_st.txt" open CITIES_ST, $cities_st; while () { /(\w+)/; push (@cities, $1); } close CITIES_ST; # randomize cities foreach (0..99) { $rand = int(rand scalar(@cities)); splice (@cities, $rand, 1); push (@cities, $_); } # create new "cities.txt" open CITIES, ">$cities"; foreach (a..z) { $city = 0; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } foreach (A..Z) { $city = 26; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } foreach (0..9) { $city = 51; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } close CITIES; # print the html code for ($i; $i<5; $i++){ print ""; }