#!/usr/bin/perl use Modern::Perl; my @f = qw(9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 7 8); foreach my $f (@f){ my $x = ($f-5)%24; say $x; }