在Perl 5中定义了负操作数的%的行为?

Cha*_*ens 5 perl modulo

直到最近(即C99),模运算符的行为是在C中定义的实现.由于Perl 5是用C编写的,它是否依赖于用于构建它的C编译器的行为?

Cha*_*ens 10

不,Perl 5定义了模运算符perlop,甚至还有测试以确保它按照记录的方式工作.

来自perl/t/op/arith.t

tryeq $T++,  13 %  4, 1;
tryeq $T++, -13 %  4, 3;
tryeq $T++,  13 % -4, -3;
tryeq $T++, -13 % -4, -1;
Run Code Online (Sandbox Code Playgroud)

但是,如果您使用integerpragma,那么您将受到C编译器的怜悯.