[thelist] Trying to use hash with non-const name

Dovalle Yankelovich dovalle at smlink.com
Wed May 1 09:42:01 CDT 2002


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
--
[ Picked text/plain from multipart/alternative ]
Hi,
below part of my code. im trying to avoid using a lot of if..else controls
(see the blue lines)
instead I want to use foreach loop (see the purple line) and assign the hash
name depend on the file im using to be the one from the red hashes
if any one have an idea I will be glad to hear it
Thanks

Dovalle


@FilesNames = (DPInfo,Cpu);

%DpInfoOperation = (
 Net =>2, ##Getting a value
 #'K,R,S,D  =>1, need to chang print format
 ##Crc Error --> =>2, ##nof... $ Time Stamp
 Retrain  =>2,
 BER   =>3, ##Printing every line

    );
%CpuOperation = (
 High=>1,
Low=>2
);

  open($CUURTRACE,$file)||die "Can't open file\n";
  print (RES "\n\t\t\t\t\tCurr file: $file\n\n");
  foreach $FileName (@FilesNames)
  {
       if ($file =~/$FileName/i)
       {
        $tmp = $FileName.Operation;  #the result should be one of :
%DPInfoOperation or %CpuOperation
        %Operation = %tmp;
         last;
       }
  }
#if($file =~/DPInfo/i)
 # {
 #  %Operation = %DPInfoOperation;
 # }
 # elsif($file =~/Cpu/i)
 # {
 #  %Operation = %CpuOperation;
 # }
  while($line=<$CUURTRACE>)
  {
   $CurrOpp = 0;
      #chomp $line;
   SWITCH:
   {
    foreach $Opp(keys(%Operation))
    {
     if ($line =~/$Opp/) { $CurrOpp = $Operation{$Opp}; last SWITCH; }
    }
   }
   if ($CurrOpp == 0){}##Do nothing
   elsif ($CurrOpp == 2)
   {
    print (RES $line);
    $tmp=++$Parameter{$Opp};

   }




  }
  #print (RES "nofNet: $Parameter{$Opp}\n");

 }

 splice (@CurrDirFiles);
 $i++;


}
close RES;






--
[ dovall1.gif was deleted, please don't send attachments with your message. ]



More information about the thelist mailing list