mhonarc-users

Re: ezmlm-mhonarc script does not work !!!

1999-04-22 13:53:57
On April 22, 1999 at 09:47, Phil Watkinson wrote:

    if ($month eq "01") { $monthname = "January " . $year }
       elsif ($month eq "02") { $monthname = "February " . $year }
       elsif ($month eq "03") { $monthname = "March " . $year }
       elsif ($month eq "04") { $monthname = "April " . $year }
       elsif ($month eq "05") { $monthname = "May " . $year }
       elsif ($month eq "06") { $monthname = "June " . $year }
       elsif ($month eq "07") { $monthname = "July " . $year }
       elsif ($month eq "08") { $monthname = "August " . $year }
       elsif ($month eq "09") { $monthname = "September " . $year }
       elsif ($month eq "10") { $monthname = "October " . $year }
       elsif ($month eq "11") { $monthname = "November " . $year }
       elsif ($month eq "12") { $monthname = "December " . $year }

Here, you can either use a hash or array to make the code simpler.
For example, if you define the following at the top of your script:

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

Then your big if/elsif block changs to:

    $monthname = $Months[int($month)-1] . " $year";

In sum, use arrays if you need to map (a range) integers to strings.
Use a hash if you need to match strings to strings.

        --ewh

----
             Earl Hood              | University of California: Irvine
      ehood(_at_)medusa(_dot_)acs(_dot_)uci(_dot_)edu      |      Electronic 
Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME

<Prev in Thread] Current Thread [Next in Thread>