JuickDiffUtility v 0.2

 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
31
32
33
34
#!/usr/bin/perl
opendir DIR, "." || die $!; # open current directory
my @files = readdir DIR; # getting list of files in current directory
closedir DIR;
my @users = grep (/^\.subscribers\.\w+$/i, @files); # extracting only needed files
foreach $user(@users){ # extracting usernames from filenames
$user =~ s/\.subscribers\.(\w+)/$1/ig;
}
@users = sort {$a cmp $b} map (lc, @users); # sorting list of users
@files = grep (/^juickdiff(\.pl)?$/i, @files);
my $juickdiff = $files[0];
if ($juickdiff eq /\s*/){
die "There is no juickdiff in current folder";
};
print "List of users, that you used early:\n";
my $i = 0;
foreach $user(@users){
print "$i: $user\n";
$i += 1;
}
print "Enter the number of the user, that you want to see:\n";
my $number = <>;
chomp $number;
if ($number =~ m/\d+/ && $number >=0 && $number <= $i){
print "getting data for $users[$number] in progress...\n";
print `perl $juickdiff $users[$number]\n`;
} else {
print "$number is not a valid number!\n"
};