[interchange] Test regex match in picture_format()

Mark Johnson <[email protected]>
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit a6c3c1dc495aa142ea7b24c110905eefc5ae1aed
Author: Mark Johnson <[email protected]>
Date:   Mon Jan 24 17:20:49 2011 -0500

    Test regex match in picture_format()
    
    Bug exposed on price pictures that do not use a point separator,
    such as Yen.

 lib/Vend/Util.pm |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/lib/Vend/Util.pm b/lib/Vend/Util.pm
index 7e2860c..d6ae6a9 100644
--- a/lib/Vend/Util.pm
+++ b/lib/Vend/Util.pm
@@ -335,8 +335,10 @@ sub picture_format {
     $pic	= reverse $pic;
 	$point	= '.' unless defined $point;
 	$sep	= ',' unless defined $sep;
-	$pic =~ /(#+)\Q$point/;
-	my $len = length($1);
+	my $len = $pic =~ /(#+)\Q$point/
+		? length($1)
+		: 0
+	;
 	$amount = sprintf('%.' . $len . 'f', $amount);
 	$amount =~ tr/0-9//cd;
 	my (@dig) = split m{}, $amount;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.