in reply to converting hash to shuffled array

Would something like this (untested) work instead:

my @imagearray = shuffle(keys %db); print qq(<a href="$db{$imagearray[0]}"><img src="/images/$imagearray[0 +]"></a>);

Basically, would it work to just put the image titles (the keys to %db, in your code) in the array, shuffle it, then refer back to the hash element whose image title (key) is in element 0, rather than trying to put the whole thing in then split it later? Just wondering...