in reply to Tracking images printed on HTML

you might use something like:
push (@ids,$id); ... $mycounter[$id] += 1;
after randomly having choosen an $img with referring $id, so you get an array with the $id of the $image as number of element and the number of views as values.
update
seem's it was alreday suggested - :-)