Sunday, July 08, 2012

[bkyisiyx] Calendar expand to page

Reformat the output of "cal" to fill up one US Letter page.

#! perl -w
# perl calendar-expand.pl 2012 | enscript -B -o /tmp/foo.ps
if (defined($ARGV[0])){
    $command="cal -h $ARGV[0]";
} else {
    $command="cal -hy"; #current year
}
open FI,"$command|" or die;
while(<FI>){
    next if $.>1 and ($.-1)%9==0;
    s/(...)(...)(...)(...)(...)(...)(...) /$1 $2 $3 $4 $5 $6 $7  /g;
    print;
    print"\n"if/^[0-9 ]+$/
}

No comments :