Thread Menge bestimmter Einträge in einer Datei filtern (7 answers)
Opened by Rambo at 2009-08-11 11:18

Rambo
 2009-08-11 14:11
#124104 #124104
User since
2003-08-14
803 Artikel
BenutzerIn

user image
Hallo zusammen,

vielen Dank für die Beispiele.
Ich habe jetzt auf Grundlage von topeg das hier draus gemacht und es funktioniert genau wie gewünscht.
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -----------------------------------------------------------------------------
# File name : sort_list.pl
# Location : FRA
# Last edited by :
# Last Checkin : 11.08.2009
# Revision : 0.1
# -----------------------------------------------------------------------------
# History:
#
#
# 11.08.2009 first version
#
# -----------------------------------------------------------------------------
#
#
#
# Last change: 11.08.2009 XXX
#
################################################################################
#
#
# ------------------------------------------------------------------
# Loaded Modules
# ------------------------------------------------------------------
use strict;
use warnings;
use threads;
use threads::shared;
#
#
# ------------------------------------------------------------------
# File open
# ------------------------------------------------------------------
open (OUT, "<result_NPU_org.txt") or die $!;
#
#
# ------------------------------------------------------------------
# Search Strings
# ------------------------------------------------------------------
my @string = qw (FQTV PSPT SNR BAGL BAGT UPG MSG);
#
#
# ------------------------------------------------------------------
# Start threads
# ------------------------------------------------------------------
my $StopDotPrintFlag : shared;
$StopDotPrintFlag = 0;
my $Interval = 1;
my $DotPrintThread=threads->new(\&DotPrintThread, $Interval);

sub DotPrintThread
{
my ($Interval, @Trash) = @_;
use IO::Handle;
autoflush STDOUT 1;
my $IntervalCount=0;
print "\n\tpls. wait getting data ";
while ($StopDotPrintFlag != 2)
{
if ($StopDotPrintFlag == 1)
{
print STDOUT ".";
}
$IntervalCount++;
sleep $Interval;
}
return $IntervalCount;
}
#
#
# ------------------------------------------------------------------
# start search
# ------------------------------------------------------------------
my %keys;
while (my $line=<OUT>)
{
for my $string (@string)
{
$keys{$1}++ if($line=~ /,($string)/);
}
$StopDotPrintFlag = 1; #Stop threads
}
#
#
# ------------------------------------------------------------------
# get search result
# ------------------------------------------------------------------
while (my ($key,$val)= each(%keys))
{
print "\n$key = $val\n";
}
#
#
# ------------------------------------------------------------------
# File close
# ------------------------------------------------------------------
close OUT;
#
#
#****************************
# End of Script
#****************************

Merci vielmals

Beste Grüsse
Remo

View full thread Menge bestimmter Einträge in einer Datei filtern