Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

RE: Random Image in HTML

by turnstep (Parson)
on Apr 25, 2000 at 01:37 UTC ( [id://8809] : note . print w/replies, xml ) Need Help??

in reply to Random Image in HTML

Some notes:
  • 'opendir' should check its result, perhaps with a "|| die"
  • 'srand' should not be in the subroutine, since it could be called more than once in the same script.
  • The whole subroutine could probably be collapsed into an inner loop.
  • If the directory is empty, the script will enter an infinite loop!
  • Outputing a 'Content-size' to the browser would be nice.
  • This does not actually return the image to the HTML page, but a location. Strange, but workable for most browsers.