(Forgive the excitement)

I just reversed the %n2m construct - the original builds a hash using map 
that lets you convert numbers to months, etc. (I probably found it here).

In keeping with my feeling that with 'map' one can do almost anything (if I 
knew how) I'm happy to have managed to build something using 'map' (without 
external help I mean). Seems easy, now. ;-)

# months into numbers...

$month = "Jan"  # for example

my %m2n;
my $x = "00";

map { $m2n{$_} = ++$x } qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);

my $mon = $m2n{$month};

# and the monstrosity it replaced...

    my %months = (
                 Jan     =>      "01",
                 Feb     =>      "02",
                 Mar     =>      "03",
                 Apr     =>      "04",
                 May     =>      "05",
                 Jun     =>      "06",
                 Jul     =>      "07",
                 Aug     =>      "08",
                 Sep     =>      "09",
                 Oct     =>      "10",
                 Nov     =>      "11",
                 Dec     =>      "12"
                 );

    my $mon = $months{$month};
#

-K  (peace and quiet here for a while - I'm off for two+ weeks vacation)
-- 
Kevin Pfeiffer
International University Bremen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to