my $locale = $ARGV[1];
AIUI, you'll want
$ARGV[0] not
$ARGV[1].
I've also added strictures and warnings to your script (to trigger any helpful diagnostics that might be lurking):
use strict;
use warnings;
use v5.10;
use POSIX qw(LC_ALL setlocale strftime);
my $locale = $ARGV[0];
say "$locale: ", POSIX::setlocale(LC_ALL, $locale);
my $march = strftime("%B", 0, 0, 0, 1, 2, 123);
say $march;
On Windows 11, perl-5.38.0, I then get:
D:\pscrpt>perl try.pl de_DE.UTF-8
Use of uninitialized value in say at try.pl line 7.
de_DE.UTF-8:
March
It seems that the
POSIX::setlocale() call is not returning anything.
The POSIX documentation suggests that the following one liner should work:
D:\>perl -MPOSIX -wle "$loc = POSIX::setlocale( &POSIX::LC_ALL, 'de' )
+; print $loc;"
Use of uninitialized value $loc in print at -e line 1.
That's not my idea of "working".
I would raise an issue about this at
https://github.com/Perl/perl5/issues.
At least then you'll get feedback from people with some expertise regarding locale settings on Windows.
BTW, for me, the C program you provided output:
C: March (5 bytes)
Cheers,
Rob
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.