Parse numbers that contain commas correctly
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 19 Apr 2014 22:07:22 +0000 (01:07 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 19 Apr 2014 22:07:22 +0000 (01:07 +0300)
lib/WWW/Search/Torrentz.pm

index 34ae025bf83ae5ec030ca1f1f3df087de805720e..6e98c38538fe407f830d4861d7e107fcafe01e0a 100644 (file)
@@ -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';
                        }
                }
 
This page took 0.010889 seconds and 4 git commands to generate.