use strict; use warnings; my @times = (5, 10, 20, 25, 30, 40, 45, 50, 55, 65, 75, 80, 90); my (@t1, @t2); for (@times) { push @{(defined $t1[-1] and $_ - 10 < $t1[-1]) ? \@t2 : \@t1}, $_; } print "@t1\n@t2\n";