damian has asked for the wisdom of the Perl Monks concerning the following question:
the code will open the flat db file and prints the image depending on the type of the image (internal,partner,or payed). the problem is the code does not rotate the images it only prints out the last image found. here's the piece of my code and see if you can fix it.... i know this is a very lame code so no flames pls.1|/pics/boy.gif|http://www.b.com|internal 2|/pics/gal.gif|http://www.g.com|partner 3|/pics/gol.gif|http://www.f.com|payed
thanks in advance.if(!open DAT, "ads.dat") { print "Error: cannot open data file!\n"; exit 1; } else { @imgdata=<DAT>; foreach $c (@imgdata) { ($id,$image,$url,$type)=split(/\|/,$c); if ($type=~/^internal|partner$/) { srand(time() ^ ($$ + ($$ << 15)) ); @imgs = ($image); $img = $imgs[int(rand($#imgs+1))]; print "Location: $img\n\n"; } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing Random Image in HTML
by merlyn (Sage) on Sep 13, 2000 at 13:14 UTC | |
|
Re: Printing Random Image in HTML
by kilinrax (Deacon) on Sep 13, 2000 at 14:49 UTC | |
by Ovid (Cardinal) on Sep 13, 2000 at 20:32 UTC | |
by damian (Beadle) on Sep 14, 2000 at 06:20 UTC | |
|
Re: Printing Random Image in HTML
by btrott (Parson) on Sep 13, 2000 at 11:00 UTC | |
by damian (Beadle) on Sep 13, 2000 at 11:25 UTC | |
|
Re: Printing Random Image in HTML
by little (Curate) on Sep 13, 2000 at 12:33 UTC | |
|
(Ovid) RE: Printing Random Image in HTML
by Ovid (Cardinal) on Sep 13, 2000 at 20:11 UTC | |
by markjugg (Curate) on Jul 04, 2002 at 14:42 UTC |