choroba gives you a solution for the problem as you present it but, more generally, if you have arrays with longer rows the number of conditions inside the grep becomes unwieldy. A nested grep solution can overcome this.
$ perl -E '
> @arr = (
> [ 1, 3, 6 ],
> [ 8, 8, 8 ],
> [ 3, 9, 0 ],
> [ 1, 4, 5, 3, 6, 9, 4, 2 ],
> [ 2, 2, 2, 2, 2, 2, 2 ],
> );
>
> @neq =
> grep {
> $zero = $_->[ 0 ];
> grep { $zero != $_ } @$_[ 1 .. $#{ $_ } ]
> } @arr;
>
> say qq{@$_} for @neq;'
1 3 6
3 9 0
1 4 5 3 6 9 4 2
I hope this is of interest.
|