#!/usr/local/bin/perl $| = 1; # tired of typing "cal" and not getting the current month? this # script, called "now", prints out last month, this month, and # next month with today in inverse video, comme ci: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon++; # 0 based $year += 1900; $nmon = $mon + 1; $nyear = $year; if ( $nmon == 13 ) { $nmon = 1; $nyear++; } $pmon = $mon - 1; $pyear = $year; if ( $pmon == 0 ) { $pmon = 12; $pyear--; } $SO = "\e[7m"; $SE = "\e[m"; open ( PREV, "cal $pmon $pyear |" ); open ( CUR, "cal $mon $year |" ); open ( FOLL, "cal $nmon $nyear |" ); $len = 24; until (eof(PREV) && eof(CUR) && eof(FOLL)) { $prev = ; chop($prev); $cur = ; chop($cur); $gotit = ($cur =~ s/(...*)(\s+)$mday(\s+)/$1$2$SO$mday$SE$3/ || $cur =~ s/(...*)(\s+)$mday$/$1$2$SO$mday$SE/); $foll = ; chop($foll); printf sprintf("%%-%ds %%-%ds %%-%ds\n", $len, ($gotit ? ($len + length($SO.$SE)) : $len), $len), $prev, $cur, $foll; }