Public paste
wikiparsel.pl
By: wikiparsel.pl | Date: Jun 1 2020 17:12 | Format: Perl | Expires: never | Size: 467 B | Hits: 848

  1. use strict;
  2. use warnings;
  3.  
  4. my ($file) = glob("~/Desktop/pagecounts-20160101-050000");
  5. $file and -f $file or die "Could not find pagecounts file!\n";
  6.  
  7. my $most_counts = 0;
  8. my $most_line;
  9.  
  10. open my $in_fh, '<', $file or die "Unable to open $file\n";
  11. while (my $line = <$in_fh>) {
  12.   next unless $line =~ /^en\s\S+\s(\S+)\s\S+\s/;
  13.   if ($most_counts < $1) {
  14.     $most_counts = $1;
  15.     $most_line = $line;
  16.   }
  17. }
  18.  
  19. print "Most popular page: $most_line\n";
  20.