in reply to Function to return last working day of month?

Date::Manip is definitely the easiest and best way to go about it, but if you're looking for something that doesn't require any CPAN modules (or you don't want to go through the trouble of installing them)...
#!/usr/local/perl -w # Calculate the last business day of the month. use strict; my $last_day = _calc_last_day(); print "Last business day of the month: $last_day\n"; sub _calc_last_day { use Time::Local; use POSIX qw(strftime); my ($_year, $_month) = split(/\./, `date +%y.%m`); chomp($_year, $_month); # Calculate the last day of the month. my $_next_year = ($_month == 12) ? $_year + 1 : $_year; my $_next_month = timelocal(0, 0, 0, 1, $_month % 12, $_next_year) +; my $_last_day = (localtime($_next_month - 86400))[3]; # Make sure it is a business day. my $_day = strftime "%a", localtime($_next_month - 86400); if ($_day eq 'Sat') { $_last_day--; } if ($_day eq 'Sun') { for (1..2) { $_last_day--; } } return "$_month/$_last_day/$_year"; }

Enjoy.

scott.