in reply to How to validate %hash = ( 'a' => 'b', ...);

as a side remark ...

... I expected omitting the redundant quotes to produce "bareword" errors under strict

use strict; use warnings; use Data::Dump qw/pp dd/; my %hash = ( accents => 'utf-8', accounting => 'money', bank => 'money'. bank2 => 'money'. bank3 => 'money', perls => 'perl' ); dd \%hash;

but funnily the auto-quoting effect of the fat comma => has higher precedence than the concat operator. (?)

{ accents => "utf-8", accounting => "money", bank => "moneybank2", moneybank3 => "money", perls => "perl", }

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: How to validate %hash = ( 'a' => 'b', ...);
by Anonymous Monk on Sep 12, 2016 at 07:29 UTC

    ... I expected omitting the redundant quotes to produce "bareword" errors under strict ... but funnily the auto-quoting effect of the fat comma => has higher precedence than the concat operator. (?)

    Um ... operator effect precedence? As different from operator precedence? I don't like that phrasing :D

    http://perldoc.perl.org/perlop.html#Comma-Operator says

    The special quoting behavior ignores precedence, and hence may apply to part of the left operand:
    print time.shift => "bbb";
    That example prints something like "1314363215shiftbbb" , because the => implicitly quotes the shift immediately on its left, ignoring the fact that time.shift is the entire left operand.

    At least this phrasing doesn't bring up precedence, but still seems forced

    First part is much better

    The => operator (sometimes pronounced "fat comma") is a synonym for the comma except thatit causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores.

    shift is the word on the left, thats the rule, no matter the "entire left operand" , big fat comma quotes the word on the left, the end :)

      Well, documented or not that's a good candidate for an extra warning.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!