usr bin perl use strict use warnings my re qr span class self lt gt sp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl
use strict;
use warnings;
my $re = qr/<span.*?class\s*=\s*"self.*?".*?>&lt;(.+?)&gt;<\/span>/;
my %users = ();
for my $file(glob('./logs/*')){
open(my $fd, '<', $file) or die "Couldn't open file";
for my $line (<$fd>){
if($line =~ m/$re/){
$users{$1} = 0 if not exists $users{$1};
$users{$1} += 1;
}
}
}
for my $key(sort { $users {$b} <=> $users {$a}} keys %users){
print $key." => ".$users{$key}."\n"
}