in reply to Using map

map processes a list and returns a list, so you need to assign the list back to your @data array (or a new array).

@data = map { #? data is skiped when plotted if($maxreject[$i]) { $_ = "?$_" if($_ > $maxclip); } if($minreject[$i]) { $_ = "?$_" if($_ < $minclip); } $i++; } @data;

That said, a for loop might be a better choice, but it should work.


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: Using map
by maderman (Beadle) on Oct 22, 2002 at 06:19 UTC
    Thanks for the quick response! However, assigning @array = map {} @data produces the following in my data:
    07/01 09:09:57 0 1 2 3 4 5 07/01 09:14:56 0 1 2 3 4 5 07/01 09:19:58 0 1 2 3 4 5 07/01 09:24:58 0 1 2 3 4 5 07/01 09:29:58 0 1 2 3 4 5 07/01 09:34:58 0 1 2 3 4 5
    Hmm.

      Sorry! Take another look, I've updated the previous answer.

      With map, the value that gets passed out it the last value in the code block. In your case it was the $i++ expression, hence the counts you got. Add the new last line I indicate above and it should fix that. I didn't notice that the first time.

      I still think this is an iffy use of map though.


      Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!