my $dates_per_day = sub { #SQL }; for (@days) { my @dates_today = $dates_per_day->($_); #zeige Termine für diesen Tag }