문제

The following code has unusual behaviour that I found to be odd. It's just part of a program that works otherwise.

 #!/usr/bin/perl -w

    use strict;

    $a = 0;
    $abc = 0;                                                                                       

 exit 0;

Due to use strict statement Perl insists that I modify the second declaration as:

my $abc = 0;

But it does not do so for $a! I tried this on multiple Linux distros and Perl versions. Could anyone explain the reason please?

도움이 되었습니까?

해결책

From perldoc strict

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

다른 팁

$a is used for sort() and as such doesn't require declaration.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top