use Date::Calc qw/:all/; . . my @date = (Localtime)[0..2]; . . # iterate through system accounts from the database while (my $account = $accounts->fetchrow_hashref) { my $plan = $plans[ $account->{'planid'} ]; # calculate the delta day count between the current date and the # date of account activation my $delta = Delta_Days((split '-', $account->{'activationdate'}), @date); if ($delta == 0) { # the delta day count will equal zero on the same day as the # account activation - this is useful for when you also want to # incorporate the sending of a welcome email or alike } else { # within this system each billing plans has a period value which # represents the number of billing systems over a single annual # period - if you are wanting to send out these emails on a # monthly basis, this variable can be replaced with the number # twelve if ($plan->{'fee'} && $plan->{'period'}) { # here is the actual calculation itself, the modulus result # of which will equal zero on days when an email should be # sent to the user my $calc = $delta % int (Days_in_Year((@date)[0..1]) / $plan->{'period'}); if ($calc == 0) { # send the email to the owner of this account } } } }