Hi all, I'm atempting to process a file and identify values greater or less than a certain max or min. These values will be skipped when I plot the resulting file with gnuplot. I'm attempting to use 'map' to process the @data array below, but it doesn't appear to work the way I expect. For example, I know there are dud values associated with $data[4], so I set $maxreject[4] to true so that these values will have a "?" put in front of the value and therefore skipped when I use gnuplot. With the code below, no "?" is appended to the dud values. The code is:
use strict; @maxreject = (); @minreject = (); $maxreject[4] = 1; $maxclip = 1E-1; $minclip = -3.0E-6; $sdate = 20020106; $edate = 20020107; open(CLOCK,"data.log") || die "data: $!"; open(OUT,">out"); while(<CLOCK>) { chomp; my($time,$date,@data) = (split / +/)[1,2,6,7,9,12,13,14]; $date =~ m/(\d\d)-(\w+)-(\d{4})/; $day = $1; $month = $months{uc($2)}; $year = $3; $now = $year.$month.$day; last if($now > $edate); if($now >= $sdate) { $i=0; map { #? data is skiped when plotted if($maxreject[$i]) { $_ = "?$_" if($_ > $maxclip); } if($minreject[$i]) { $_ = "?$_" if($_ < $minclip); } $i++; } @data; print OUT "$day/$month $time @data\n" ; } } #end of while close(OUT); close(CLOCK);
Any help appreciated. Thanks, Stacy.

In reply to Using map by maderman

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.