use strict; behaviour not working as expected in Perl wrt $a and $b

前端 未结 1 1509
耶瑟儿~
耶瑟儿~ 2021-01-21 04:46

I have written a sample perl code:

use strict;
use warnings;
$a=1;
$b=2;
if($b==2) {
    $a=3;
}
print $a;

Ideally, when I run this code, it sh

相关标签:
1条回答
  • 2021-01-21 05:07

    $a and $b are special variables, and thus are not rising error when used with strict.

    From perldoc strict,

    Because of their special use by sort(), the variables $a and $b are exempted from this check.

    0 讨论(0)
提交回复
热议问题