ozo,Average!

The $b variable is from the Infile,this statement: runt1!9!14(The 2nd value,it can be 3values or 5values or 9values)
Infile:
runt1!9!14
runt2!9!14
runt3!9!15
runt4!9!25
runt5!9!3


Then How do i calculate my average of the values for each parameter and print the average value to the end of each line(See output file) in the output file e.g
-9.960116E+02!+1.002406E-03!
means that -9.960116 is to the power of 2,1.002406 is to the power of -3.

ps:Your codes did not include this calculation of the power to 3?It only sum up the total is it?

Output file(Contains only 2values but it can be 3 or 5 or 9 values):

s1!NE2 40/40 Vth0!+9.939227E+02!+9.982348E+02!avg(value calculated)!
s2!NE2 40/40 Vth0!-9.960116E+02!+1.002406E-03!avg(value calculated)!    

s1!Vth Vb/2.5!+3.985872E-08!+3.948130E-08!avg(value calculated)!
s2!Vth Vb/2.5!+3.974027E-08!+3.971276E-08!avg(value calculated)!


Below is my codes:
open(FILE1,"infile") || die "Can't open infile because $!";
open(FILE2,">outfile") || die "Can't open outfile because $!";

while( <FILE1> )
{
  ($a,$b,$c) = split(/!/);
  $c = sprintf("%02d",$c);
  open (FILE3,"<$a") || die "Can't open $a because $!";
  while( <FILE3> )
  {
    next unless /SYS_WAFERID!$c\b/.../SYS_WAFERID!$c\b/;
    next unless ($para,@values) = (/([^!]+)!.*!/,/!([-+][-+\d.E]+)/g);
    push @para,$para unless $para{$para};
    if($b == 3)
    {
      for('s1'..'s3')
      {
         push @{$para{$para}{$_}},shift @values;
      }
    }
    if($b == 5)
    {
      for('s1'..'s5')
      {
         push @{$para{$para}{$_}},shift @values;
      }
    }
    if($b == 9)
    {
      for('s1'..'s9')
      {
         push @{$para{$para}{$_}},shift @values;
      }
    }
  }
  close FILE3;
}
for $p ( @para )
{
  if($b == 3)
  {
    for $s ('s1'..'s3' )
    {
       print FILE2 join"!",$s,$p,@{$para{$p}{$s}};
       $avg =0;
       for(@{$para{$p}{s}})
       {
          $avg = $avg + $_;
       }
       $avg/=@{$para{$p}{$s}};
       print FILE2 "!$avg!\n";
       #print FILE2 "\n";
    }
    print FILE2 "\n";
  }
  if($b == 5)
  {
    for $s ('s1'..'s5' )
    {
        print FILE2 join"!",$s,$p,@{$para{$p}{$s}};
        print FILE2 "\n";
    }
    print FILE2 "\n";
  }
  if($b == 9)
  {
    for $s ('s1'..'s9' )
    {
        print FILE2 join"!",$s,$p,@{$para{$p}{$s}};
        print FILE2 "\n";
    }
    print FILE2 "\n";
  }
}

How do i solve my problem of getting !avg(0)!
Pls help,thanks!!
yu12koeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
for(@{$para{$p}{s}})
should be
for(@{$para{$p}{$s}})
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.