#!/usr/bin/env perl use strict; use warnings; use Date::Calc 'Delta_Days'; my @dates = ('2005-09-27', '2019-12-22', '2018-10-24', '1999-12-31'); my @start = split (/-/, shift @dates); while (0 < @dates) { local $" = '-'; my @end = split (/-/, shift @dates); print "@start to @end is " . Delta_Days (@start, @end) . " days\n"; @start = @end; }