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

Later when I saw this section again, I forgot why I split it...

There's an easy fix to that. Now that you've seen from AnomalousMonk's and ikegami's replies why

use constant { zed=>0, one=>1, two=>2, }; use constant repos=>(qw(oss non-oss debug));
was required rather than having repos defined in the same anonymous-hash, all you have to do is change that to
use constant { zed=>0, one=>1, two=>2, }; use constant repos=>(qw(oss non-oss debug)); # NOTE to future self: ca +nnot be in the `use constant { ... }`: # because an array cannot be the value for a key in an anonymous h +ash; # to create a constant array, it has to be in a separate `use cons +tant` line; # do not try to optimize this back into the `use constant {...}` b +ecause it won't work! # Really, I mean it!
(though feel free to use your own commenting style)

Replies are listed 'Best First'.
Re^2: use constant; RHE of solo confusing in list
by perl-diddler (Chaplain) on Dec 06, 2019 at 17:12 UTC
    Yep! Comments added. I hate comments, cuz they can become out-of-date and/or separated from the code. But right above repos (repotypes):
    # do not combine Repotypes w/constants above: get list-squashing effec +t;
    Sigh...Oh well...
      separated from the code

      hence at least starting the comment on the same line, which lessens the chances of it getting separated. I originally was going to post it as a single-line comment, but it was huge that way, so I separated it for easier reading in the post.