6 my $cachefile = shift @ARGV || die "usage: $0 cache.file [filename.to.save]";
8 die "$0: cannot read $cachefile";
10 my $savefile = shift @ARGV;
12 open CACHE, "<$cachefile";
18 while ($hrcount > 0) {
20 if ($line =~ /<hr>/) { $hrcount--; }
21 if ($line =~ /https?:.+\/([^\/<]+)</) {
24 if ($line =~ /Content-Disposition:.+filename=(")?([\w.]+)(")?/) {
28 print STDERR "$0: filename from cache: '$filename'\n";
30 $savefile = $filename;
32 print STDERR "$0: save file to '$savefile'\n";
35 while ($hrcount > 0) {
37 if ($line =~ /<hr>/) { $hrcount--; }
40 $line = substr $line, 15;
42 open SAVE, ">$savefile" || die "$0: cannot write $savefile";
46 while ($hrcount > 0) {
47 print SAVE hex2bin($line);
50 if ($line =~ /<hr>/) { $hrcount--; }
53 print STDERR "$0: done\n";
58 $str = substr $str, 11, 64;
60 return pack("H*", join("", split(" ", $str)));