in reply to Re: Get element count of CONSTANT list (aref))
in thread [SOLVED] Get element count of CONSTANT list (aref))

++ tybalt89, I had thought about and actually tested that as well, but I can't use that. If I used postfix-deref, then that would force the encompassing distribution (or other consumers) to require 5.20 at minimum, which I refuse to go above 5.10.

Besides, it results in the same type of behaviour:

use warnings; use strict; use feature 'say'; use constant STEPPER_SEQUENCE => [ [qw(1 0 0 1)], [qw(1 0 0 0)], [qw(1 1 0 0)], [qw(0 1 0 0)], [qw(0 1 1 0)], [qw(0 0 1 0)], [qw(0 0 1 1)], [qw(0 0 0 1)], ]; use constant STEP_COUNT => STEPPER_SEQUENCE->@*; say STEP_COUNT;

Output:

ARRAY(0x17985b8)ARRAY(0x17981f8)ARRAY(0x17c8e68)ARRAY(0x17edc90)ARRAY( +0x17edd80)ARRAY(0x17a7708)ARRAY(0x17ee0c8)ARRAY(0x1805590)

Replies are listed 'Best First'.
Re^3: Get element count of CONSTANT list (aref))
by haukex (Archbishop) on Mar 13, 2018 at 11:59 UTC
    Besides, it results in the same type of behaviour:

    In list context, yes, but like @{...} you can force it to scalar context: 0+STEPPER_SEQUENCE->@* is 8. And BTW, there is also STEPPER_SEQUENCE->$#* which will returns 7. tybalt89's code forced the scalar context with the dot . operator.