From: Marius Gavrilescu Date: Sat, 19 Apr 2014 22:07:22 +0000 (+0300) Subject: Parse numbers that contain commas correctly X-Git-Tag: 0.001003~8 X-Git-Url: http://git.ieval.ro/?p=www-search-torrentz.git;a=commitdiff_plain;h=287bea8a811cebb30c41ddfd52d54893358760a9 Parse numbers that contain commas correctly --- 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'; } }