#!/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 ( ){    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 ( )  {    #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 ( )  {    $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 ( ) {     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;