In advance of you providing answers to jcwren's questions, I have one sort of suggestion to make that I think will work for a number
of setups. warning : it involves a relatively complex data structure (to fully grok it, you'll need to
read up on how to use references in Perl!)
Suppose you've got a runtime variable that selects the language, what you can do is have a hash, whose keys are the names of the various languages, and whose values are *references to* anonymous arrays, which hold the names of the months in that language.
The syntax below is not sacrosanct, personally if I could figure out right at this moment
how to use the qw(...) to get the names of the months without all the fiddly quotes, I'd be happier,
but the following seems suitable for small to medium-sized projects.
Here's a code snippet (that won't work cut n' paste! =):
use strict; # =)
my %months = ( 'English'=> ['January', 'February' ... ],
'French'=> ['Janvier', 'Fevrier', ... ],
'Italian'=> ['gennaio', 'febbraio', ...],
#etc ...
);
What's nice about this setup is that since the month *numbers* are universal across the
different languages (well, give or take certain Eastern Orthodox churches etc. =) you can access the
name of the month quite easily :
# $language is set at run time and would be one of 'English',
# 'Italian' etc. -- the keys of your $months hash
# also assumes $month_number ranges from 1 to 12; if it's 0 to 11, eli
+minate the '-1'
my $month_name = $month{$language}[$month_number-1];
HTH
|