in reply to Month info from 'date'

You can get the current month from localtime. Then it's pretty easy to map the month number to a string with a simple array: @monthname = qw(Jan Feb Mar Apr May Jun Jul ...); Put the two together:
my $thismonth = (localtime)[4]; my $lastmonth = ($thismonth == 0)? 11 : $thismonth-1; print $monthname[$lastmonth], "\n";
Substitute for print as necessary.

HTH

Replies are listed 'Best First'.
Re: Re: Month info from 'date'
by Masem (Monsignor) on Jun 23, 2001 at 00:58 UTC
    Note that you don't even need the $thismonth check; an index of -1 will return the last element from the array (eg December).


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: Re: Month info from 'date'
by Dr. Mu (Hermit) on Jun 23, 2001 at 20:09 UTC
    You can skip the acrobatics altogether with:
    print qw(Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov)[(localtime)[ +4]]
      Ok... here is how I ended up doing it... tell me if this looks terrible:
      my $month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)[(local +time)[4]-1]; print "$month\n";
      --Neb