in reply to displaying an image

When writing CGI scripts it's always useful to use CGI. In your case something like the following may work.
use CGI qw(:standard); #...your other code... print img({src => "$courselocation/images/$value"});

$|=$_="1g2i1u1l2i4e2n0k",map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g