in reply to Re: 36 Conditions in If Statement [sendhelp]
in thread 36 Conditions in If Statement [sendhelp]]
The approach you suggest is very ++nice. It can easily be adapted to other cases; e.g., a case in which the comparison may vary with each tuple of indices.
At a slight performance cost, the subroutine block of all could be made a bit more readable:use strict; use warnings; use List::Util qw(all); # create and populate my @matrix as before ... my @tuples = ( [1, 0, 4, 0], [2, 0, 4, 1], [3, 0, 4, 2], [4, 1, 4, 0], [5, 1, 4, 1], [6, 1, 4, 2], ... [9, 4, 6, 0], [8, 4, 6, 1], [7, 4, 6, 2], ); do_something() if all { $_->[0] == $matrix[$_->[1]][$_->[2]][$_->[3]] +} @tuples;
Give a man a fish: <%-{-{-{-<
|
|---|