-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcount_id_mirror.pl
40 lines (32 loc) · 1.03 KB
/
count_id_mirror.pl
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
35
36
37
38
39
40
#!/usr/bin/perl -w
# script to count the size of the mirror of id Software's Doom
# sums up the bytecount from the output of ls -laR on the mirror
# open the ls -laR file
# exit if we are not passed in a filename
if (! $ARGV[0]) { print "Usage: $0 ls_output\nExiting...\n"; exit 1;}
# open the file for reading
print "$0: opening $ARGV[0]\n";
open(LSOUT, $ARGV[0]);
# a counter would be nice
$counter = 0;
#$tmpcounter = 0;
# loop thru the file
while (<LSOUT>) {
# any line without a d or '-' as the first character, discard
#if ( /^-/ || /^d/ ) { # we've got a match
if ( /^-/ ) { # we don't download directories, so don't count them
# we've got a match
# we want the 4th column from 0 (left edge)
# /\s+/ == one or more spaces
chomp($_);
@line = split (/\s+/, $_);
#print join(":", @line);
#print "\n";
$counter += $line[4];
#$tmpcounter +=1;
#if ($tmpcounter == 10) {print "Tempcounter limit: $counter\n"; exit 1;}
} # if ( /^-/ || /^d/ )
} # while (<LSOUT>)
print "Total bytes are: $counter\n";
close(LSOUT);
exit 0;