in reply to use constant; RHE of solo confusing in list

In

use constant { zed => 0, one => 1, repos => (qw(oss non-oss debug)), two => 2, };
the
{ zed => 0, one => 1, repos => (qw(oss non-oss debug)), two => 2, }
part is actually an anonymous hash constructor that passes its value (a hash reference) to the constant pragma for further processing. So this hash has to be something sensible, and
c:\@Work\Perl\monks>perl -wMstrict -MData::Dumper -le "print Dumper { zed => 0, one => 1, repos => (qw(oss non-oss debug)), two => 2, }; " $VAR1 = { 'non-oss' => 'debug', 'repos' => 'oss', 'one' => 1, 'zed' => 0, 'two' => 2 };
ain't it. As you can see,  'non-oss' ends up as a key with  'debug' as its value because  qw(oss non-oss debug) is just a flattened list within the constructor.

So no, you can't use the  { ... } version of constant as you initially wished because a valid hash must be built first.

The  use constant repos2 => qw(oss non-oss); version works because the  qw() expression is what the  repos2 function created by constant is built to return. (Update: constant distinguishes between this syntax and the  { ... } hash syntax by virtue of the type of the first argument passed to it.

c:\@Work\Perl\monks>perl -wMstrict -le "use constant [ qw(a b c d) ]; " Invalid reference type 'ARRAY' not 'HASH' at -e line 1 BEGIN failed--compilation aborted at -e line 1. c:\@Work\Perl\monks>perl -wMstrict -le "use constant qw(A b c d); print A; " bcd
)


Give a man a fish:  <%-{-{-{-<