diff options
author | Marius Halden <marius.h@lden.org> | 2015-02-14 06:43:43 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2015-02-14 06:43:43 +0100 |
commit | e4cc3f0733b59e1cb730a083ab60230f1739fed9 (patch) | |
tree | 2f6da961b2653df5e6c92a08db2e3593a7b41af7 | |
parent | 83bafd752c4617e9c719dd76ccece81ff3843d50 (diff) | |
download | appdrift-stats-e4cc3f0733b59e1cb730a083ab60230f1739fed9.tar.gz appdrift-stats-e4cc3f0733b59e1cb730a083ab60230f1739fed9.tar.bz2 appdrift-stats-e4cc3f0733b59e1cb730a083ab60230f1739fed9.tar.xz |
Better error handling
-rwxr-xr-x | stats.pl | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -78,17 +78,19 @@ for my $group (@group_names) { my $content = get("http://".$group_info->{'server'}->{$group}); - for my $line (split /\n/, $content) { - last if (defined($users) && defined($posts) && defined($comments)); - last if ($line =~ /Last activity/i); - next if (length $line < 1); - - if ($line =~ /Users:[^0-9]*(\d+)/i) { - $users = $1; - } elsif ($line =~ /Posts:[^0-9]*(\d+)/i) { - $posts = $1; - } elsif ($line =~ /Comments:[^0-9]*(\d+)/i) { - $comments = $1; + if (length $content > 1) { + for my $line (split /\n/, $content) { + last if (defined($users) && defined($posts) && defined($comments)); + last if ($line =~ /Last activity/i); + next if (length $line < 1); + + if ($line =~ /Users:[^0-9]*(\d+)/i) { + $users = $1; + } elsif ($line =~ /Posts:[^0-9]*(\d+)/i) { + $posts = $1; + } elsif ($line =~ /Comments:[^0-9]*(\d+)/i) { + $comments = $1; + } } } |