#!/usr/bin/perl -w

use strict;
use warnings;
use Calendar::Simple;

my @months = qw(January February March April May June July August
                September October November December);

my $mon = shift || (localtime)[4] + 1;
my $yr  = shift || (localtime)[5] + 1900;

my @month = calendar($mon, $yr);

my $mon_name = $months[$mon - 1];
my $pad = int((20 - length("$mon_name $yr")) / 2);

print "\n", ' ' x $pad, "$months[$mon - 1] $yr\n";
print "Mo Tu We Th Fr Sa Su\n";
foreach (@month) {
  print map { $_ ? sprintf "%2d ", $_ : '   ' } @$_;
  print "\n";
}
