-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarcsumproc
More file actions
executable file
·53 lines (40 loc) · 1.67 KB
/
Copy pathwarcsumproc
File metadata and controls
executable file
·53 lines (40 loc) · 1.67 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -anl
# Copyright (C) 2014 Bibliotheca Alexandrina
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Refer to perlrun(1) for options in the #!. -n runs Perl in Awk mode.
# -a turns on automatic line splitting (@F). -l is for automatic line
# processing (chomp the '\n' and set the ORS to '\n').
# NOTE: This is a classic program with a single input stream and a
# single output stream. Use the stdio streams the OS provides. This
# relieves the program from having to process command-line args as well
# as from having to open/close file handles.
#
# Also, keep in mind that in non-strict Perl, initializing variables to
# undef accomplishes nothing.
# INPUT
#
# warc_filename offset uri date hash hash_ext
# $F[0] $F[1] $F[2] $F[3] $F[4] $F[5]
if ($hash ne $F[4] && $hash_ext ne $F[5])
{
($refersto_uri, $refersto_date, $hash, $hash_ext) = @F[2..5];
# First copy.
$copy = 1;
# First copy refers to nothing.
print "$F[0] $F[1] $F[2] $F[3] $F[4] $F[5] $copy - -";
}
else
{
# Duplicate.
$copy++;
print "$F[0] $F[1] $F[2] $F[3] $F[4] $F[5] $copy $refersto_uri $refersto_date";
}