usr bin perl use strict use warnings use FindBin qw Bin opendir DIR Bi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);
opendir DIR, $Bin || die $!;
my @users = sort {$a cmp $b} map {lc} grep {/^\.subscribers\.\w+$/i} readdir DIR;
closedir DIR;
my $juickdiff = -e "$Bin/juickdiff" ? 'juickdiff' : 'juickdiff.pl';
die "There is no juickdiff in current folder" if !-e "$Bin/$juickdiff";
print "List of users, that you used early:\n";
for (0..$#users) {
$users[$_] =~ s/\.subscribers\.(\w+)/$1/ig;
print "$_: $users[$_]\n";
}
print "Enter the number of the user, that you want to see:\n";
my $number = <>;
chomp $number;
if ($number =~ m/\d+/ && $number >=0 && $number <= $#users){
print "getting data for $users[$number] in progress...\n";
print `perl $juickdiff $users[$number]\n`;
} else {
print "$number is not a valid number!\n"
}