=David wrote:

 # Change the month into a numerical problem.  If only the months
 # were alphabetically arranged this would be so much easier!
 $amon = 1 if $amon eq 'Jan'; $amon = 2 if $amon eq 'Feb';
 $amon = 3 if $amon eq 'Mar'; $amon = 4 if $amon eq 'Apr';
 $amon = 5 if $amon eq 'May'; $amon = 6 if $amon eq 'Jun';
 $amon = 7 if $amon eq 'Jul'; $amon = 8 if $amon eq 'Aug';
 $amon = 9 if $amon eq 'Sep'; $amon = 10 if $amon eq 'Oct';
 $amon = 11 if $amon eq 'Nov'; $amon = 12 if $amon eq 'Dec';
=cut


## Instead of this you can write once:

sub month   {
  $Mon = shift;
  $_ = "janfebmaraprmayjunjulaugsepoctnovdec";   ## English; German:  
"JanFebMrzAprMaiJunJulAugSepOktNovDez";
  m,$Mon,gi;
  sprintf "%02s", pos()/3; }


##  ... and then call it many times; for example: to find out the number for February,
##       as  month(feb)   or  month(Feb):
print "The Month Feb has the number ", $a = month(feb), ".\n";  ##  will print  "02"

##   1. HTH;
##   2. Question to everybody:  Why does the following line (without   $a =  ) not 
yield a propper result?

print "The Month Feb has the number ",  month(feb), ".\n";  ##  will print  "00"

##              Detlef





Reply via email to