develooper Front page | perl.perl5.porters | Postings from July 2001

Questions about I18N::Langinfo

Thread Next
From:
Philip Newton
Date:
July 8, 2001 00:12
Subject:
Questions about I18N::Langinfo
Message ID:
qo1gktse8bg91qs4v6fit8b951d0vrvnkq@4ax.com
First, a question about the docs. The patch to perllocale.pod said this:

> +The following example will import the langinfo() function itself
> +(implicitly) and (explicitly) three string constants: a string for the
> +abbreviated first day of the week (the numbering starts from Sunday =
> +1) and two strings for the affirmative and negative answers for a
> +yes/no question in the current locale.
> +
> +    use I18N::Langinfo qw(ABDAY_1 YESSTR NOSTR);
> +
> +    print ABDAY_1, "? [", YESSTR, "/", NOSTR, "] ";
> +
> +In other words, in the "C" (or English) locale the above will print:
> +
> +    Sun? [y/n] 

But Langinfo.pm has this:

> +The following example will import the langinfo() function itself
> +(implicitly) and (explicitly) three constants to be used as arguments
> +to langinfo(): a constant for the abbreviated first day of the week (the
> +numbering starts from Sunday 1) and two more constant for the affirmative
> +and negative answers for a yes/no question in the current locale.
> +
> +    use I18N::Langinfo qw(langinfo ABDAY_1 YESSTR NOSTR);
> +
> +    my ($abday_1, $yesstr, $nostr) = map { langinfo } qw(ABDAY_1 YESSTR NOSTR);
> +
> +    print "$abday_1? [$yesstr/$nostr] ";
> +
> +In other words, in the "C" (or English) locale the above will probably print:
> +
> +    Sun? [y/n] 

The first paragraph is the same in each case -- it claims to import
langinfo implicitly and three constants explicitly. But the second
example has langinfo in the import list passed to 'use' while the first
does not. Due to the 'implicit', I would assume the first example is
correct... but if langinfo() is in @EXPORT_OK but not @EXPORT, I'm not
sure how it'll get imported implicitly, so the docs may be wrong.

Another question: the second example uses "map { langinfo }", implying
to me that langinfo uses $_ if it is not passed an explicit argument. Is
that correct? If so, it should be documented IMO.

A third question: the first example prints out ABDAY_1 and gets 'Sun'.
The second example appears to print out langinfo(ABDAY_1) to get 'Sun'.
From the code, the second appears to be correct as the constants are
integers, not strings.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About