Bill Lovett wrote:
>
> Can anyone suggest a better/cooler way to populate this hash? I'm
> doing ultra simple date checking, so this is all I really need, but
> there must be another way to do it...
>
> my %monthNames;
> $monthNames{"Jan"} = 0;
> $monthNames{"Feb"} = 1;
> $monthNames{"Mar"} = 2;
> $monthNames{"Apr"} = 3;
> $monthNames{"May"} = 4;
> $monthNames{"Jun"} = 5;
> $monthNames{"Jul"} = 6;
> $monthNames{"Aug"} = 7;
> $monthNames{"Sep"} = 8;
> $monthNames{"Oct"} = 9;
> $monthNames{"Nov"} = 10;
> $monthNames{"Dec"} = 11;
Try
my $monthnames = (Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun
=> 5, Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov => 10, Dec => 11);
But that'S still very boring, because we only have to know the order of
months.
So better is perhaps;
local $i = 0; my %monthnames = map {$_ => $i++} qw(Jan Feb Mar Apr May
Jun Jul Aug Sep Oct Nov Dec);
Of course, for month names there are already some functions and modules.
It's your job to find them. (rtfm :-))
Best Wishes,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]