Eug*_*kov 2 perl operators operator-precedence assignment-operator perl-hash
我必须表达:
%MON = months => 1, end_of_month => 'limit'; # months => undef
%MON = ( months => 1, end_of_month => 'limit' );
Run Code Online (Sandbox Code Playgroud)
为什么第一个表达式只产生一个months带undef值的键?它们之间有什么区别?
参见perlop。=优先级高于=>
Run Code Online (Sandbox Code Playgroud)%MON = months => 1, end_of_month => 'limit';
相当于:
(%MON = "months"), 1, "end_of_month", "limit"
Run Code Online (Sandbox Code Playgroud)
尽管:
Run Code Online (Sandbox Code Playgroud)%MON = ( months => 1, end_of_month => 'limit' );
是:
%MON = ("months", 1, "end_of_month", "limit")
Run Code Online (Sandbox Code Playgroud)