-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7zl_diffable
39 lines (34 loc) · 1.17 KB
/
7zl_diffable
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
#!/usr/bin/perl
use warnings;
use strict;
use English;
use Data::Dumper;
# NB!!!! when using git-bash-perl (by definition ON WINDOWS), "paragraph mode" will BREAK to the extent STDIN contains DOS newlines!!!
# first read the whole fscking file into a variable
my $text;
{ # https://www.perlmonks.org/?node_id=1952
local $/ = undef;
$text = <>;
}
$text =~ tr /\r//d; # dos2unix
# now read from the string (as a filehandle) in "paragraph mode" https://stackoverflow.com/a/12562193
{
local $/ = "";
open my $ifh, '<', \$text;
my @out;
while ( <$ifh> ) { chomp;
# print ((split /\n/, $_)[0]);
# print( "\$_: ", $_, "\n" );
my @fields = split "\n";
@fields = grep { m! = \S! } @fields;
# print( "\@fields: ", Dumper( \@fields ), "\n" );
my %ff = map { split qr(\s*=\s*) } @fields;
# print( "\%ff: ", Dumper( \%ff ), "\n" );
# print "\n";
push @out, join( "\t", lc $ff{Path} # , ($ff{Modified} // '?')
, ($ff{Size} // '?') , ($ff{CRC} // '?') );
# print $ff{Path}, " ", $ff{Modified} // '?', " ", $ff{Size} // '?', " ", $ff{CRC} // '?', "\n" if exists $ff{Path};
}
@out = sort @out;
print "$_\n" for @out;
}