Before my $rand = int(rand(3))+1; my $imagename = "sean.jpg"; $imagename = "jay.jpg" if ($rand == 2); $imagename = "airplane.jpg" if ($rand == 3); After my $imagename = ("sean.jpg", "jay.jpg", "airplane.jpg")[(int rand 3)]; Syntax stolen from http://www.rollmop.org/oneliners/perl.html j