caciqueman has asked for the wisdom of the Perl Monks concerning the following question:

I am "trying" to get this to work, but I can't seem to find an answer in either the cookbook or programming perl. What I would like to do is randomize an entire array of jpgs in a database of about 50, then take 20 or so and print them out to a template page. What happens is that it puts ONE picture on the page, 20 times, instead of 20 thumbnails once each. Could you please help a newkid out ? Here is what I sometimes refer to as my "code".
#!/usr/bin/perl -w print "Content-type: text/html\n\n"; $dir = "/home/usr/public/images/"; $view = "view.html"; $number_to_show = 15; $title = "Your Title Could Go Here"; srand( time() ^ ($$ + ($$ << 15)) ); opendir DIR, "$dir"; my @arr = grep -f, grep /\.jpg$/i, map "$dir/$_", readdir DIR; $n = @arr; foreach (reverse 0..$n) { my $pic = splice(@arr, rand $n, 1); push @arr, $pic; $#arr = $number_to_show; } &print_it(); sub print_it { open (PAGE, "$dir$view") || die ("I am unable to open the template $vi +ew"); while (<PAGE>) { s/%%title%%/$title/g; s/%%images%%/@arr/g; print $_; } close (PAGE); }