【问题标题】:Perl operator eqv is not workingPerl 运算符 eqv 不起作用
【发布时间】:2023-11-16 09:23:01
【问题描述】:

下面的代码不起作用,但我不知道为什么。

my $q = (1, 2) eqv (1, 3);
print "$q \n";

我正在使用 Perl v5.14。还有“eqv”和“==”有什么区别?

【问题讨论】:

  • "eqv" 是 perl6 中的新运算符。
  • Perl 5 和 Perl 6 都是很棒的语言,但它们是不同的语言。如果您想学习其中一个或两个,请确保您知道您阅读的教程、网页或答案中提到了哪个。
  • 在编写 Perl 5 程序时,始终以 use strictuse warnings 开头,直到您确切知道为什么推荐它们。

标签: perl operator-keyword equality


【解决方案1】:

Perl5 中没有像 eqv 这样的运算符。我认为您正在寻找eq 运营商。

要查看eq== 运算符之间的区别,请参见:

perl string compare with “eq” vs “==”

eq vs. ==

阅读本文了解更多信息:

What's the deal with all the different Perl 6 equality operators

Comparison of the Perl equality operators

【讨论】:

  • 阅读答案中给出的最后一个链接。