for (1 .. 8) { if((my $first = $_ % 3 == 0) ... (my $last = $_ % 3 == 0)) { printf "%s first:%s last:%s\n", $_, $first?'yes':'no', $last?'yes':'no', ; } }