From 287bea8a811cebb30c41ddfd52d54893358760a9 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 20 Apr 2014 01:07:22 +0300 Subject: [PATCH] Parse numbers that contain commas correctly --- lib/WWW/Search/Torrentz.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/WWW/Search/Torrentz.pm b/lib/WWW/Search/Torrentz.pm index 34ae025..6e98c38 100644 --- a/lib/WWW/Search/Torrentz.pm +++ b/lib/WWW/Search/Torrentz.pm @@ -23,6 +23,8 @@ sub _native_setup_search{ $self->user_agent->delay(2/60); } +sub fullint ($) { int (shift =~ y/0-9//cdr) } + sub _parse_tree{ my ($self, $tree) = @_; my $found = 0; @@ -31,8 +33,7 @@ sub _parse_tree{ my $result_count = $tree->find('h2')->as_text; if (defined $result_count && $result_count ne 'No Torrents Found') { $result_count =~ s/orrents.*//; - $result_count =~ y/0-9//cd; - $self->approximate_result_count(int $result_count); + $self->approximate_result_count(fullint $result_count); } for my $node (@potential_results) { @@ -49,8 +50,8 @@ sub _parse_tree{ $verified = int ($span->as_text =~ m,^\d+,) when 'v'; $age = $span->as_text when 'a'; $size = $span->as_text when 's'; - $seeders = int $span->as_text when 'u'; - $leechers = int $span->as_text when 'd'; + $seeders = fullint $span->as_text when 'u'; + $leechers = fullint $span->as_text when 'd'; } } -- 2.39.2