From e4cc3f0733b59e1cb730a083ab60230f1739fed9 Mon Sep 17 00:00:00 2001 From: Marius Halden Date: Sat, 14 Feb 2015 06:43:43 +0100 Subject: Better error handling --- stats.pl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/stats.pl b/stats.pl index 7bd118e..ce7ebbd 100755 --- a/stats.pl +++ b/stats.pl @@ -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; + } } } -- cgit v1.2.3