If you're truly interested in modifying your script to support internationalization, you may be interested in
Locales (see
perllocale). Since all these definitions and settings are included in most advanced OS's, it makes sense to make use of them if your needs extend beyond something simple like this (otherwise that's a lot of overhead for simply getting month names out of it). Consider:
use POSIX qw(locale_h strftime); # arturo's fix
use locale; # not necessarily needed in *this* case
# locale_h above and the setlocale() calls below
# are only needed in normal circumstances if you
# want to work outside of your machine's default
# locale.
for $locale (qw{ en fr de }) {
setlocale(LC_TIME, $locale);
for (0..11) {
print "Locale $locale\n---------\n";
# strftime is now localized to $locale
print strftime("%B", 0, 0, 0, 1, $_, 96);
print "\n";
}
}
Note: Code samples are for conceptual use only and generally are not meant to be cut/pasted into a production application. Always 'use strict', have a thorough understanding of the code you use, and check the return values of functions and handle errors according to your needs. - Fastolfe
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.