#!/usr/bin/perl -w use strict; my @numbers = (1, 2, 5, 7, 8, 9); for my $counter ( 1..10 ) { my $img; # Check whether this value of counter is in @numbers for my $i ( @numbers ) { if ($i == $counter) { $img = "image" . ($counter-1); last; } } # If $img is still undefined then this value is missing if (!defined $img) {$img = "error.bmp"} print "$counter $img\n"; }