Why is 开发者_如何学Cthere no error issued by strict
:
use strict;
$a = $a + 1;
$a and $b are special globals used by sort
, so they're always defined. Try it with $c instead and you will get an error.
Although strict
does not complain about the special $a
and $b
variables,
perlcritic will detect their usage:
Magic variables should be assigned as "local"... (Severity: 4)
$a
is a special global variable. It doesn't need to be declared. See perldoc perlvar.
In Perl there are some global variables. Here $a
and $b
are used in the sort function.
I think you might have noticed, like in this statement:
sort { $a <=> $b } @array_name ;
精彩评论