2 # Summarize .zi input in a .zi-like format.
4 # Courtesy Ken Pizzini.
8 #This file released to the public domain.
10 # Note: error checking is poor; trust the output only if the input
11 # has been checked by zic.
17 while (s/^\s*((?:"[^"]*"|[^\s#])+)//) {
22 my $type = lc($fields[0]);
24 @fields >= 3 or warn "bad continuation line";
25 unshift @fields, '+', $contZone;
30 if ($type eq 'zone') {
31 # Zone NAME STDOFF RULES/SAVE FORMAT [UNTIL]
32 my $nfields = @fields;
33 $nfields >= 5 or warn "bad zone line";
35 #this splice is optional, depending on one's preference
36 #(one big date-time field, or componentized date and time):
37 splice(@fields, 5, $nfields-5, "@fields[5..$nfields-1]");
39 $contZone = $fields[1] if @fields > 5;
40 } elsif ($type eq 'rule') {
41 # Rule NAME FROM TO - IN ON AT SAVE LETTER/S
42 @fields == 10 or warn "bad rule line";
43 } elsif ($type eq 'link') {
44 # Link TARGET LINK-NAME
45 @fields == 3 or warn "bad link line";
46 } elsif ($type eq 'leap') {
47 # Leap YEAR MONTH DAY HH:MM:SS CORR R/S
48 @fields == 7 or warn "bad leap line";
50 warn "Fubar at input line $.: $origline";
52 print join("\t", @fields), "\n";