First, neither your question nor your code makes it clear (to me, anyway; YMMV) precisely what you're trying to do; what the result of all this processing is supposed to provide, other than "values in @powers."
But, in hopes your answers may shed some light on the matter:
In your line 7, did you intend for $i < @in; to be $i < $#in; ? See replies :-(
... or, maybe $i < ( $#in + 1 );?
@in is the entire array; not a count of elements
And does this -- in any way -- resemble what you want?
#!/usr/bin/perl use Modern::Perl; use Data::Dumper; # 942489 my @in= qw/1 2 3 4 5 6 7 8 9 10 11 1.155031267e-5 13 14 101 102 103 104 105 106 107 108 109 110 111 1.13 113 114 181 182 183 184 185 186 187 188 189 190 191 0.192 193 194/; my $MaxAgc0 = "1.15503129132678e-005"; # MaxAgc0 is a consta +nt my @Attn; my @powers; for ( my $i = 0; $i < $#in; $i += 14 ) { for ( my $j = 1; $j <= $in[$i]; $j++ ){ # $j is *WHAT ?* my $num = ( $in[$i+12]*$MaxAgc0 ); push @Attn, $num / $in[$i + 10]; } } for (my $i = 0; $i < $#in; $i += 14) { push @powers, ( $in[$i + $_] - $Attn[$i] ) / 100 for (2..9); } say "\@Attn next" . "-" x20; print Dumper @Attn; say "\@powers next" . "~" x20; print Dumper @powers;
Output
@Attn next-------------------- $VAR1 = '1.36503698065892e-005'; $VAR2 = '1.17584266594528e-005'; $VAR3 = '1.17584266594528e-005'; $VAR4 = '1.17584266594528e-005'; $VAR5 = '1.17584266594528e-005'; $VAR6 = '1.17584266594528e-005'; $VAR7 = '1.17584266594528e-005'; ... $VAR101 = '1.17584266594528e-005'; $VAR102 = '1.17584266594528e-005'; $VAR103 = '1.16712585982235e-005'; # value changes $VAR104 = '1.16712585982235e-005'; $VAR105 = '1.16712585982235e-005'; ... $VAR282 = '1.16712585982235e-005'; $VAR283 = '1.16712585982235e-005'; @powers next~~~~~~~~~~~~~~~~~~~~ $VAR1 = '0.0299998634963019'; $VAR2 = '0.0399998634963019'; $VAR3 = '0.0499998634963019'; $VAR4 = '0.0599998634963019'; $VAR5 = '0.0699998634963019'; $VAR6 = '0.0799998634963019'; $VAR7 = '0.0899998634963019'; $VAR8 = '0.0999998634963019'; $VAR9 = '1.02999988241573'; $VAR10 = '1.03999988241573'; $VAR11 = '1.04999988241573'; $VAR12 = '1.05999988241573'; $VAR13 = '1.06999988241573'; $VAR14 = '1.07999988241573'; $VAR15 = '1.08999988241573'; $VAR16 = '1.09999988241573'; $VAR17 = '1.82999988241573'; $VAR18 = '1.83999988241573'; $VAR19 = '1.84999988241573'; $VAR20 = '1.85999988241573'; $VAR21 = '1.86999988241573'; $VAR22 = '1.87999988241573'; $VAR23 = '1.88999988241573'; $VAR24 = '1.89999988241573';
WAG: Given your reference to a "set", could it be that @in is supposed to be an AoA?
And, given the recommendation that SOPW include a minimal sample of code and data which reproduce the problem, why bother with the else clause when @in is (pseudo-)instantiated at your line 2?
In reply to Re: Can you help profile this?
by ww
in thread Can you help profile this?
by Fighter2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |