#!/usr/bin/perl -w use strict; use LWP::Simple; use vars qw($in_file @imgdata @imgs $num $id $image $url $type $format $out_file); $in_file = 'ads.dat'; @imgdata = ; @imgs = grep {/\|(?:internal|partner)$/} @imgdata; $num = int(rand($#imgs) +1); ($id, $image, $url, $type) = split /\|/, $imgs[$num]; $url = $url . $image; $format = $1 if $image =~ /\.(\w+)$/; $format = 'jpeg' if $format =~ /^jpe?g$/; $out_file = get($url); print "Content-type: image/$format\n\n"; print $out_file; __DATA__ 1|/images/dibona_sm.gif|http://perlmonks.org|internal 2|/images/usermonkpics/ovidmonk.gif|http://perlmonks.org|partner 3|/pics/gol.gif|http://www.f.com|payed #### Random image