From perldoc strict
Because of their special use by sort(), the variables $a and $b are exempted from this check
سؤال
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.