Grumble. So I changed it:use constant { zed => 0, one => 1, repos => (qw(oss non-oss debug)), two => 2, }; #output: Constant name 'non-oss' has invalid characters at -e line 3. BEGIN failed--compilation aborted at -e line 7.
Later when I saw this section again, I forgot why I split it...and tried combining it again with same results. Tried breaking things apart, but not seeing the diffs visualized:tperl use constant { zed=>0, one=>1, two=>2, }; use constant repos=>(qw(oss non-oss debug)); '
Had to put assignment to k in BEGIN block for use-constants to see its value. But now no errors, but feeling uneasy about the result, I added some P statement to show me the structure(s):> tperl # (alias tperl='perl -I/home/law/bin/lib -we'\''use strict; us +e P;') our $k; BEGIN{our $k={ zed => 0, one => 1, repos => [qw(oss non-oss debug)], two => 2, };} use constant $k; use constant repos2=>(qw(oss non-oss));'
Definitely a problem -- in this "solution"sic. Repos isn't a list, but a ref to a list. Grrr. Tried putting an array around the list:tperl our $k; BEGIN{our $k={ zed => 0, one => 1, repos => [qw(oss non-oss debug)], two => 2, };} P "k=%s", $k; use constant $k; use constant repos2=>(qw(oss non-oss debug)); P "repos=%s", [repos]; P "repos2=%s", [repos2];' #output: k={one=>1, two=>2, zed=>0, repos=>["oss", "non-oss", "debug"]} repos=[["oss", "non-oss", "debug"]] repos2=["oss", "non-oss"]
But then, fail:repos => @{[qw(oss non-oss debug)]},
I should just give up -- not worth the hassle, but does anyone see an easy way to combine these two constant definitions so that 1 statement will suffice for 2? Don't waste too much time...since I'll have already gone to the separate definition to move on, but sure seems a somewhat quirky situation, where because the definition in 1 def results in repos+defintion being combined with the outer list (because it is a list within a list, ala this mistake:Constant name 'non-oss' has invalid characters at -e line 10. BEGIN failed--compilation aborted at -e line 10.
Which we'd more quickly recognize as a problem if it was written:my ($x,$y) = (qw(1 2 3), qw(4 5 6));
Which most would see as a standard list-flattening gotcha. Which I skimmed over when I tried to combine my constant statements due to thinking that "qw" somehow would group them... Bzzzt. Anyway, Just don't see a safe & easy way to combine the definitions. Counterpoint?my ($x,$y) = ( (1,2,3), (4,5,6));
Thanks!
In reply to use constant; RHE of solo confusing in list by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |