Skip Menu |

This queue is for tickets about the Perl6-Form CPAN distribution.

Report information
The Basics
Id: 119967
Status: resolved
Priority: 0/
Queue: Perl6-Form

People
Owner: Nobody in particular
Requestors: Stuart.Long [...] hsn.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Zero value not printing correctly
Date: Wed, 25 Jan 2017 11:13:48 +0000
To: "bug-Perl6-Form [...] rt.cpan.org" <bug-Perl6-Form [...] rt.cpan.org>
From: "Long, Stuart" <Stuart.Long [...] hsn.net>
Perl6-Form-0.06 perl 5.16.3 on RHEL7 Example: use Perl6::Form; use strict; use warnings; my @vals = (0.23, 1.14); print form "{]]].[}", \@vals ; Output: #perl foo 0.23. 1.14 Investigation: Culprit appears to be sub jnum, lines 385-398. if ($integral) { local $SIG{__WARN__} = sub { $fail = 1 }; $str = sprintf('%*d',$val{width},int($orig)); } else { local $SIG{__WARN__} = sub { $fail = 1 }; $str = sprintf('%*.*f',$val{width},$places,$orig); } if ($fail) { $_[0] = $huh; } else { my ($w,$p) = ($str =~ /^\s*(.*)\.(.*)$/g); # floating point ($w,$p) = ($str =~ /^\s*(.*)$/,"") if !$w; # integer If the substring to the left of the decimal point ($w from the first RE) is zero, then the !$w triggers, and the string is interpreted as an integer, with bogus results. Possible solution: Since the preceding logic already branches on whether or not the value is floating point or integer, move the $w and $p assignments there, and eliminate the cascading RE decision: my ($w, $p); if ($integral) { local $SIG{__WARN__} = sub { $fail = 1 }; $str = sprintf('%*d',$val{width},int($orig)); ($w,$p) = ($str =~ /^\s*(.*)$/,""); # integer } else { local $SIG{__WARN__} = sub { $fail = 1 }; $str = sprintf('%*.*f',$val{width},$places,$orig); ($w,$p) = ($str =~ /^\s*(.*)\.(.*)$/g); # floating point } if ($fail) { $_[0] = $huh; } else { # my ($w,$p) = ($str =~ /^\s*(.*)\.(.*)$/g); # floating point # ($w,$p) = ($str =~ /^\s*(.*)$/,"") if !$w; # integer This results in properly formatted output: #perl foo 0.23 1.14 http://www.hsn.com<http://www.hsn.com/> [http://images.hsn.com/images/corpemail/2013_hsn_logo_prod.jpg]

Message body is not shown because it is too large.

Subject: Re: [rt.cpan.org #119967] Zero value not printing correctly
Date: Thu, 26 Jan 2017 10:17:28 +1100
To: bug-Perl6-Form [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Very much appreciated, Stuart! You saved me a great deal of effort tracking down the issue. I'm deeply grateful. Patched and reuploaded. Damian
Subject: RE: [EXTERNAL] Re: [rt.cpan.org #119967] Zero value not printing correctly
Date: Fri, 27 Jan 2017 13:35:46 +0000
To: "bug-Perl6-Form [...] rt.cpan.org" <bug-Perl6-Form [...] rt.cpan.org>
From: "Long, Stuart" <Stuart.Long [...] hsn.net>
Happy to be of service. Am I famous now? Show quoted text
-----Original Message----- From: damian@conway.org via RT [mailto:bug-Perl6-Form@rt.cpan.org] Sent: Wednesday, January 25, 2017 6:19 PM To: Long, Stuart Subject: [EXTERNAL] Re: [rt.cpan.org #119967] Zero value not printing correctly ************************************************************************* This email is from an external sender. If you think it is malicious or spam, please do not open any attachments or links and forward to ITSpam@hsn.net ************************************************************************* <URL: https://rt.cpan.org/Ticket/Display.html?id=119967 > Very much appreciated, Stuart! You saved me a great deal of effort tracking down the issue. I'm deeply grateful. Patched and reuploaded. Damian
Subject: Re: [EXTERNAL] Re: [rt.cpan.org #119967] Zero value not printing correctly
Date: Sat, 28 Jan 2017 07:47:25 +1100
To: bug-Perl6-Form [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> Happy to be of service. Am I famous now?
Yes. For at least 15 minutes. Also see the banner at the top of: https://metacpan.org/release/DCONWAY/Perl6-Form-0.007 ;-) Damian