我目前正在记录所有Perl 5的运算符(参见perlopref GitHub项目),我也决定包含Perl 5的伪运算符.对我来说,Perl中的伪运算符是任何看起来像运算符的东西,但实际上不仅仅是一个运算符或其他一些语法.我已经记录了我熟悉的四个:
()=
算子的数量=()=
goatse/countof运算符~~
标量上下文运算符}{
爱斯基摩吻操作员这些伪运算符还有哪些其他名称,你知道我错过了哪些伪运算符吗?
=head1 Pseudo-operators
There are idioms in Perl 5 that appear to be operators, but are really a
combination of several operators or pieces of syntax. These pseudo-operators
have the precedence of the constituent parts.
=head2 ()= X
=head3 Description
This pseudo-operator is the list assignment operator (aka the countof
operator). It is made up of two items C<()>, and C<=>. In scalar context
it returns the …
Run Code Online (Sandbox Code Playgroud) 一个家伙Stackoverflower 试图@ARGV
在他的END
街区使用,但无法.
为什么@ARGV
仅BEGIN
使用以下单行在块内定义:
$ perl -lne 'BEGIN{ print "BEGIN" if @ARGV }
print "MIDDLE" if @ARGV }
{ print "END" if @ARGV ' file
BEGIN
Run Code Online (Sandbox Code Playgroud)
perldoc perlrun
对此事没有任何启示.这里发生了什么?