Global Symbol "$file" requires explicit package name at C:\Sinteria\oldclean.pl line 10
Begin not safe after errors--compilation aborted at C:\Sinteria\oldclean.pl line 10
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
# Deletes players which haven't logged for a week and have level below 30
use strict;
use warnings;
use Tie::File;
my $days = 7;
my $minlevel = 30;
my $counter = 0;
for $file (glob "../data/players/*"){
next unless $file =~ /xml$/;
open(my $fh, "<", $file) or die $!;
@content = <FILE>;
$_ = "@content";
close(FILE);
my ($account) = $_ =~ /account="(\d+)"/;
my ($lastlogin) = $_ =~ /lastlogin="(\d+)"/;
my ($level) = $_ =~ /level="(\d+)"/;
my ($playername) = $_ =~ /name="(\w+)"/;
if ((time() - $lastlogin) > $days*24*3600 && $lastlogin > 0 && $level < $minlevel){
for my $local_file($file,"../data/accounts/$account.xml","../data/vip/$account.xml"){
tie my @array,'Tie::File',$local_file) or die $!;
@array = grep{$_ !~ /$playername/}@array;
untie @array;
}
print "$file\n";
$counter++;
}
}
print "$counter acccounts deleted\n";