http://www.perlmonks.org?node_id=155160


in reply to Re: Converting output from numeric values to text
in thread Converting output from numeric values to text

Couldn't .... resist .... temptation:
my %month = map { $_ => 1 } qw(jan feb mar apr may jun jul aug sep oct + nov dec);
Or a hash slice:
my %month; my @month = qw(jan feb mar apr may jun jul aug sep oct nov dec); @month{@month} = (1) x @month;
UDPATE:
sorry about that - please allow me to fix it:
my @month = qw(jan feb mar apr may jun jul aug sep oct nov dec); my %month = map { $_ => $month[$_] } (0..$#month); ... $m_name = $month{$m_number};

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) 2Re: Converting output from numeric values to text
by PrakashK (Pilgrim) on Mar 29, 2002 at 04:59 UTC
    I don't think your code produces what the original poster OnTheEdge wanted. Yours would result in a hash with the month names as keys and 1 as values for each.

    He wants to convert month numbers into month names.

    $m_name = qw(jan feb mar apr may jun jul aug sep oct nov dec)[$m_numbe +r];
    /prakash