When does the difference between a string and a number matter in Perl 5?

后端 未结 4 1747
逝去的感伤
逝去的感伤 2020-12-17 19:30

If a string in Perl 5 passes looks_like_number, it might as well be a number. For instance,

my $s = \"10\" + 5;

results in $s

4条回答
  •  无人及你
    2020-12-17 20:21

    When dealing with bitwise operators. 123 ^ 456 is 435, but "123" ^ "456" is "\x05\x07\x05". The bitwise operators work numerically if either operand is a number.

提交回复
热议问题