Hi Monks,

I have a very simple problem which is driving me slightly mad. The question relates to a variable named @unique_slopes which is within a few nested loops. When I print the contents of the variable it contains many numbers (is this just because it is within the loops??). I need all these numbers I store in @unique_slopes to be in the same array (so I can iterate through it and find what i'm after). Is there a better way for me to store these numbers so that I can split the array and iterate through it? I eventually want to use the for loop at the bottom but am just having problems as everything in @unique_slopes is in $unique_slopes[0].

Cheers monks.

foreach my $line (@data) { # lots of irrelevent code for (my $i =1; $i < @array; $i++) { # once again lots of irrelevent code %gradient_hash = map {$matching_temps[$_] => $gradients[$_]} 0 .. + $#matching_temps; while (($key2, $value2) = each (%gradient_hash)) { if (($value2 > 0.1) || ($value2 < -0.1)) { @steep_grads = $key2 . '?' . $value2; @slopes = $value2; } } @unique_slopes = grep {! $seen2{$_} ++} @slopes; print "@unique_slopes<P>"; } }
This is what I eventually want to do with @unique_slopes
for (my $i = 1; $i < @unique_slopes; $i++) { if (($unique_slopes[$i] < -0.1) && ($unique_slopes[$i-1] > 0.1)) + { print "PEAKS: $unique_slopes[$i-1] $unique_slopes[$i]<P>"; } }

update (broquaint): added formatting + removed extraneous whitespace in code


In reply to going loopy by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.