in reply to Month Names

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

Replies are listed 'Best First'.
RE: Oddities
by arturo (Vicar) on Sep 28, 2000 at 02:11 UTC

    Interesting ... when I do

    use POSIX qw(strftime locale_h);
    I get ":locale_h" is not exported by the POSIX module at locale.pl

    But when I do

    use POSIX qw(locale_h strftime);
    Everything's fine ..

    So, who knows what's going on? Is this some kinda weird bug, or is it documented behavior?

    Philosophy can be made out of anything -- or less

      I don't think it is documented, and it is due to trying to grandfather something in.

      POSIX.pm has an import method which is a wrapper around Exporter which is meant to allow things matching /^\w+_h$/ to have ":" appended making them tags. If you look at Exporter's documentation, tags for groups only work if the first element is a tag. So in your first example the second element is turned into a tag, and Exporter barfs on it not being exported. In your second example all works.

      For a hack to fix it, find POSIX.pm, search for "import", and add a sort of @list before it calls Exporter's import function.