[Perl] Multilingual date

Reuven M. Lerner reuven at lerner.co.il
Wed Feb 13 07:40:15 PST 2002


>>>>> Shlomo Yona writes:

  Shlomo> How can set up my locales from Perl (rather than counting on
  Shlomo> them to be set in the environment)?

Use the POSIX "setlocale" subroutine, whose first argument indicates
which part of the locale you want to set:

    my @locales = qw(cs_CZ fr_FR de_DE);

    use POSIX qw(LC_ALL setlocale strftime);

    foreach my $locale (@locales)
    {
	setlocale(LC_ALL, $locale);
	$now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
	print "Locale '$locale': '$now_string'\n";
    }

Reuven



More information about the Perl mailing list