#!/usr/bin/perl -w use strict; use Date::Calc qw(Calendar); sub parseCalendar { my ($year, $month) = ( scalar(@_) == 2 ) ? @_ : split(' ', `date +"%Y %m"`); my $cal = Calendar($year, $month); my @cal = split(/\n/, $cal); splice(@cal, 0, 3); # get rid of the first three lines (don't need em); my @rv = map { $_ = substr($_, 1, length); [split /\s{4}|\s{2}/]; } @cal; return @rv; } my @cal = parseCalendar(); my $i = 1; foreach my $cal_line (@cal) { print "Week ", $i++, ":"; foreach my $day (@$cal_line) { $day ||= " "; print "$day "; } print "\n"; }