#! /usr/bin/perl use strict; use warnings; use DateTime; # functions to set/check for business days { # set defaults; 1-5 (Mo-Fr) are business days # see: http://search.cpan.org/perldoc?DateTime#$dt-%3Eday_of_week() # for information which number is which day of week my %business_day; @business_day{1..5} = (1)x5; # function to (re)set business days sub set_business_days { %business_day = (); $business_day($_} = 1 for @_; } # check if given day of week is a business day sub is_business_day { my $wday = shift; return 1 if $business_day{$wday}; return 0; } } # or 1..3 for a shorter week; using 1..5 here is redundant, as they are already predefined set_business_days( 1..5 ); my $day1 = DateTime->now( time_zone => 'Europe/Berlin' ); my $add = 7; while ( $add ) { $day1->add( days => 1 ); $add-- if is_business_day( $day1->wday ); } print $day1->ymd, $/;