in reply to Can you help profile this?

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; ?
... or, maybe $i < ( $#in + 1 );?
@in is the entire array; not a count of elements
See replies :-(

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?

Replies are listed 'Best First'.
Re^2: Can you help profile this?
by BrowserUk (Patriarch) on Dec 08, 2011 at 22:32 UTC
    In your line 7, did you intend for $i < @in; to be $i < $#in; ? ... or, maybe $i < ( $#in + 1 );? @in is the entire array; not a count of elements

    How does someone who's been around here as long as you, miss the fact that an array reference @a in a scalar context (as provided by a comparison operator), renders the number of elements in the array. Ie. exactly the same number as $#a + 1?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Is that a trick question?

      ... and I don't even know whether to follow that with a smiley or a frown. So I guess the best sequel is to say "My bad; apologies!."

      And likewise to Riales for Re^2: Can you help profile this?

      ++, both, and - -, /me.
Re^2: Can you help profile this?
by Riales (Hermit) on Dec 08, 2011 at 22:34 UTC

    Regarding the bit about line 7:

    An array evaluated in scalar format returns the length of the array. So @in would indeed have returned a count of its elements.

    Also, $#in would return the last index of @in. This would mean that the middle expression in your for loops to: $i <= $#in.