Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.40 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. my %cumCount;
  5. my $totalCount;
  6.  
  7. for (my $cnt=1;$cnt<=30;$cnt++) {
  8.     open(IN, "Downloads/$cnt.aspx") or die "Can't read $cnt.aspx\n";
  9.     print STDERR "Reading Downloads/$cnt.aspx\n";
  10.     my $foundPosts=0;
  11.     while(<IN>) {
  12.         chomp;
  13.         if ($_ =~ /--- Posts ---/) {
  14.             $foundPosts=1;
  15.             print "HI: $_\n";
  16.             while($_ !~ /--- Replies ---/) {
  17.                 $_=<IN>;
  18.                 chomp;
  19.                 print "NOW THIS:$_\n";
  20.                 next if (/Show official posts/);
  21.                 if (!/^\s*<option value="\S+">(\S+)\s*\((\d+)\)<\/option>\s*$/) {
  22.                     print STDERR "WARNING: $_\n";
  23.                     die "Unexpected syntax on $cnt.aspx line $.\n$_\n" if ($_!~/--- Replies ---/);
  24.                 }
  25.                 else {
  26.                     my $poster=$1;
  27.                     my $count=$2;
  28.                     print "$count votes from $poster\n";
  29.                     $cumCount{$poster}+=$count;
  30.                     $totalCount+=$count;
  31.                 }
  32.             }
  33.             close(IN);
  34.             print "NOW GOT: $_\n";
  35.         }
  36.     }
  37.     close(IN);
  38.     die "Error: didn't find post listings in $cnt.aspx\n" if (!$foundPosts);
  39. }
  40.  
  41. print "Total posts: $totalCount\n";
  42. foreach my $person (sort {$cumCount{$b} <=> $cumCount{$a}} keys %cumCount) {
  43.     print "$person $cumCount{$person}\n";
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement