Why don't you return the standing list?
sub NUCLEOTIDES () {qw(A C G T)}
print for NUCLEOTIDES;
or even a list in a list context and a ref array in a scalar context:
sub NUCLEOTIDES () {wantarray ? qw(A C G T) : [qw(A C G T)]}
print for NUCLEOTIDES;
print NUCLEOTIDES->[2];
if you also often need to refer to individual items.
source
share