7 Einträge, 1 Seite |
1
2
3
4
my $file = '/Pfad/zur/datei.txt';
my $result = `grep -c "^channel" $file`; # Backticks
chomp $result;
print "Es sind $result Kanaele\n";
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
#!/usr/bin/perl
#require 'ctime.pl';
use POSIX qw(strftime);
$in = $ARGV[0];
open ( IN, "<$in") || die "ERROR, can't open $in";
sub getcfg()
{
while ( <IN> ){
if ( $_ =~ /\[adudata.*\]/){
return 0;
}
if ( $_ =~ /starttime=.*/){
@starttime= split ("=",$_);
}
if ( $_ =~ /iSampleRate=.*/){
@iSampleRate= split ("=", $_);
}
if ( $_ =~ /szLabel=.*/){
@szLabel= split ("=", $_);
}
if ( $_ =~ /SensUnit=.*|MeasUnit=.*/){
@SensUnit= split ("=", $_);
}
if ( $_ =~ /startPtime=.*/){
@startPtime= split ("=", $_);
}
if ( $_ =~ /iSampleRate=.*/){
@iSampleRate=split ("=", $_);
}
if ( $_ =~ /iChGroup=.*/){
@iChGroup=split ("=", $_);
}
if ( $_ =~ /iRPMChannel=.*/){
@iRPMChannel=split ("=", $_);
}
}
};
sub printdata()
{
while ( <IN> )
{
#test auf zahl
if ($_ =~ /^([+-]?\d+(\.\d+)?([Ee][+-]?\d+)?)/ ){
print OUT "$_";
}
else{
return 0;
}
}
};
sub printheader() #An dieser Stelle soll abgefragt
#werden wieviele channels es gibt.
{
printf (OUT "ch $ch[1]"."\n");
while ( <IN> )
{
$anz = `grep -c "^aduchannel" $_`;
chomp $anz;
printf (OUT "number of channels $anz"."\n")
}
printf (OUT "Samplerate $iSampleRate[1]");
printf (OUT "divided by Gain 1 "."\n");
};
while ( <IN> )
{
if ( $_ =~ /\[aduchannel.*\]/ ){
chop;chop;
@ch= split ("aduchannel",$_);
$zeile= $ARGV[0];
@name= split ('-',$zeile);
$out = sprintf ("%s_ch%d.txt", $name[0] , $ch[1] , $szLabel[1] );
&getcfg();
$timestr=strftime("%Y%m%d-%H.%M",localtime($starttime[1]));
$out = $name[0]."_".$timestr."_ch".$ch[1]."_".$szLabel[1].".txt";
open ( OUT, ">$out" ) || die "ERROR, can't open $out";
}
if ( $_ =~ /\[adudata$ch[1]\]/ ){
&printheader();
&printdata();
}
}
close IN;
close OUT;
7 Einträge, 1 Seite |