Thread Unterschiedliche MD5 Ergebnisse (35 answers)
Opened by Rambo at 2006-05-11 18:46

Rambo
 2006-05-11 20:03
#65991 #65991
User since
2003-08-14
803 Artikel
BenutzerIn

user image
Dann werde ich es leider nicht einsetzen.

Habe noch eine Verlaufskontrolle eingebaut evtl. kann es
mal jemand benötigen.
Code: (dl )
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ------------------------------------------------------------------
# loaded modules
# ------------------------------------------------------------------
use strict;
use warnings;
use Digest::MD5;
use Cwd;
use File::Find;
use threads;
use threads::shared;
#
#
# ------------------------------------------------------------------
# start threads
# ------------------------------------------------------------------
my $StopDotPrintFlag : shared;
sub DotPrintThread
{
my ($Interval, @Trash) = @_;
use IO::Handle;
autoflush STDOUT 1;
my $IntervalCount=0;
while ($StopDotPrintFlag != 2)
{
if ($StopDotPrintFlag == 1)
{
print STDOUT ".";
}
$IntervalCount++;
sleep $Interval;
}
return $IntervalCount;
}
#
#
# ------------------------------------------------------------------
# start programm
# ------------------------------------------------------------------
my $dir = getcwd;
my @files;
find(\&get_dir,$dir);

$StopDotPrintFlag = 0;
my $Interval = 1;
my $DotPrintThread = threads->new(\&DotPrintThread, $Interval);
$StopDotPrintFlag = 1;

for my $file(@files)
{
my $md5 = Digest::MD5->new;
open FILE, $file;
binmode(FILE);
while(<FILE>) { $md5->add($_); }
my $digest = $md5->hexdigest;
close FILE;

open(my $fh, ">>md5_check.txt") or die $!;
print $fh "\nDigest is $digest for $file\n";
close $fh;
}

$StopDotPrintFlag = 2;
my $NumberOfPrintedDots=$DotPrintThread->join;
print "\napplied time was ".$NumberOfPrintedDots*$Interval." seconds\n";

sub get_dir
{
push(@files,$File::Find::name) if(-f $File::Find::name);
}

Fehlt nur noch etwas Feinschliff.

Gruss
Rambo

View full thread Unterschiedliche MD5 Ergebnisse