in reply to Array element removal

It's not clear how you're deciding what arrays should be removed.
You deleted the third array from @data, because it contained the third element in @compare. That is,    [ 4, 5 ] contains 5  therefore delete. But what if it had been    [ 5, 0 ] Would it get deleted in that case?

jdporter
...porque es dificil estar guapo y blanco.

Replies are listed 'Best First'.
Re: Re: Array element removal
by jdporter (Paladin) on Dec 17, 2002 at 23:12 UTC
    Assuming that the critical value has to be in the second position in the array, and if you don't mind building up a new array to replace the old one:
    my @new_data; for my $i ( 0 .. $#data ) { $data[$i][1] != $compare[$i] and push @new_data; } # replace: @data = @new_data;
    As an aside, you are using global variables unnecessarily. Your code will be a lot clearer and cleaner, and less error prone, if you use lexical variables properly. use warnings; and use strict; to let perl help you write better code.

    jdporter
    ...porque es dificil estar guapo y blanco.

      I assume that he doesn't want the second elements in the arrays referenced in @data to be contained anywhere in @compare. Your code only checks elements in @data and @compare with the same index. The question wasn't very well stated though.

      -sauoq
      "My two cents aren't worth a dime.";
      

        Your crystal ball must be tuned better than mine ;^)

        If your interpretation is the question that was asked, even with the insight of your interpretation, I can't derive the filter to extract that signal from the noise.


        Examine what is said, not who speaks.

Re: Re: Array element removal
by The_Rev (Acolyte) on Dec 17, 2002 at 23:19 UTC
    NO, I'm only looking at @array->1 elements