You probably have your paths mixed up.
- Can you request the images in your browser using http://localhost/data/images/night.jpg ? (This is assuming your cgi-bin url is http://localhost/cgi-bin/)
- Can you run the script on your web server from the command line? What's the output?
- Which line is /var/www/cgi-bin/index.pl line 30 ?