On a quick note doesn't split "||" split on every space (update:i.e. the mysterious spot between each character)?. I believe you have to replace the "||" (pipes are special in regular expressions) for "\|\|".
Another way to do what your doing (untested):
use strict;
use List::Util qw/shuffle/;
my @imagearray = shuffle keys %db;
my ($name,$url) = ($imagearray[0],$db[$imagearray[0]);
print qq(<a href="$url"><img src="/images/$name"></a>);