develooper Front page | perl.perl5.porters | Postings from February 2013

Re: [perl #116919] Examples in I18N::Langinfo pod won't run due tofatal errors

Thread Previous | Thread Next
From:
Aaron Trevena
Date:
February 26, 2013 07:46
Subject:
Re: [perl #116919] Examples in I18N::Langinfo pod won't run due tofatal errors
Message ID:
CAJWQ4V3yhB2tszmgZ6BiWnB40xw9FV-zm2E9AVCSCBp-T65qVg@mail.gmail.com
On 26 February 2013 03:05, James E Keenan via RT
<perlbug-followup@perl.org> wrote:
> On Mon Feb 25 02:52:23 2013, aaron.trevena@gmail.com wrote:
>> Hi,
>>
>> There is something wrong in the pod for I18N::Langinfo, seems to have
>> not changed since at least 5.10
>>
>> If you actually run the example in the pod :
>>
>>    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] ";
>>
>> You will get a fatal runtime error :
>> Not enough arguments for I18N::Langinfo::langinfo at langinfo.pl line
>> 2, near "langinfo }"
>>
>> Doesn't seem much point in details which perl compiler options etc I
>> have, as that example will never work unless perl or I18N::Langinfo
>> has had a significant change in behaviour since perl 5.10
>>
>> Fix is to remove the qw string quoting and refer to variables instead
>> of strings and then pass them as an argument to langinfo :
>>
>>     map { langinfo($_) } (DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6,
>> DAY_7)
>>
>> regards,
>>
>> Aaron
>>
>>
>>
>
> I have attached which corrects the POD with code that executes.
>
> Does it suffice?  Please review.
>
> Thank you very much.
> Jim Keenan
>
>
>
> From 606a6c2f435902dfe01e012b1b3bff5e6d40611d Mon Sep 17 00:00:00 2001
> From: James E Keenan <jkeenan@cpan.org>
> Date: Mon, 25 Feb 2013 22:01:44 -0500
> Subject: [PATCH] Correct bad example in POD.
>
> Problem reported by Aaron Trevena++.
>
> For: RT #116919
> ---
>  ext/I18N-Langinfo/Langinfo.pm |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/ext/I18N-Langinfo/Langinfo.pm b/ext/I18N-Langinfo/Langinfo.pm
> index 0b6ef2a..95bb8cf 100644
> --- a/ext/I18N-Langinfo/Langinfo.pm
> +++ b/ext/I18N-Langinfo/Langinfo.pm
> @@ -103,7 +103,8 @@ 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);
> +    my ($abday_1, $yesstr, $nostr) =
> +        map { langinfo($_) } qw(ABDAY_1 YESSTR NOSTR);
>
>      print "$abday_1? [$yesstr/$nostr] ";
>
> --
> 1.6.3.2
>
>

The qw// breaks stuff too - you need to pass and argument and use the
actual constants rather than strings :

The patch gives a different error (on perl 5.10) :
Argument "ABDAY_1" isn't numeric in subroutine entry at test.pl line 3.
Argument "YESSTR" isn't numeric in subroutine entry at test.pl line 3.
Argument "NOSTR" isn't numeric in subroutine entry at test.pl line 3.

use the change I posted initially? :)

A


-- 
Aaron J Trevena, BSc Hons
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Consulting

Thread Previous | 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