1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/usr/bin/perl
- # this script parses lines like this from a parameter.xml file
- #<Para SimTag="TEST418" StimContrast="1.050000" InputStrength="0.200000" ExExStrength="0.180000" ExExRange="0.030000" ExInhStrength="1.250000" ExInhRange="0.080000" />
- $FileName="parameter.xml";
- my $RefParaNames = ReadParaNames($FileName);
- my @ParaNames=@$RefParaNames;
- print "ParaNames=$#ParaNames\n";
- my $NParas = MinAB($#ARGV, $#ParaNames) + 1;
- print "ARGV[0]= $ARGV[0] \n";
- # generate regular expressions for each parameter
- for (my $i=0; $i<$NParas; ++$i) {
- $RegExpList[$#RegExpList+1] = "$ParaNames[$i]=\"$ARGV[$i]";
- print $RegExpList[$#RegExpList]."\n";
- }
- open(FILE, "<$FileName");
- while(<FILE>) {
- my $NoHitCount=0;
- foreach $RegExp (@RegExpList) {
- if (!/$RegExp/i) {
- $NoHitCount++;
- }
- }
- if ($NoHitCount == 0) {
- print $_;
- }
- }
- close FILE;
-
-
- sub Usage()
- {
- print "usage:\n";
- print "showspikes.pl ";
- foreach $Name (@ParaNames) {
- print " <$Name>";
- }
- print "\n";
- }
- # read parameter names from xml file
- sub ReadParaNames(*)
- {
- my $FileName = shift;
- open(FILE, "<$FileName");
- my @ParaNames;
- while(<FILE>) {
- if (/<Para SimTag=\"[a-z0-9]+\"(.*=\".*)$/i) {
- $_=$1;
- # print $_;
- while(/ ([a-z0-9]+)=\"[^\"]+\"(.*)/i) {
- # print $1."\n";
- $ParaNames[$#ParaNames+1] = $1;
- $_=$2;
- }
- last;
- }
- }
- close FILe;
- return \@ParaNames;
- }
- ##############
- sub MaxAB(**)
- {
- my $a=shift;
- my $b=shift;
- return ($a>$b) ? $a : $b;
- }
- sub MinAB(**)
- {
- my $a=shift;
- my $b=shift;
- return ($a<$b) ? $a : $b;
- }
|