sub direction{ local $_; push @_, $_[0]; $_ += $a->[0] * $b->[1] - $a->[1] * $b->[0] while ($a,$b)=(shift,$_[0]), @_; $_ < 0; } my @unitCubeAnti = ([0,0],[0,1],[1,1],[1,0]); print direction(@unitCubeAnti) ? 'Anticlockwise' : 'Clockwise'; my @unitCubeClock = reverse @unitCubeAnti; print direction(@unitCubeClock) ? 'Anticlockwise' : 'Clockwise';