Why doesn't Perl build warnings about undeclared $ a?

Can someone please explain the code below to me. This behavior has been around for some time (tested on 5.8.5, 5.8.8, 5.10.1, 5.12.2), so should there be a reason for this?

$ perl -M5.012 -E '$aa=2'
Global symbol "$aa" requires explicit package name at -e line 1.

$ perl -M5.012 -E '$a=2'

Thank.

+5
source share
2 answers

This is in strict :

Due to their special use by sort (), the variables $ a and $ b are exempt from this check.

Always check documents . Most of the answers are there :)

+15
source

$a ( $b ) . sort, . sort { $a <=> $b } @list. perldoc perlvar perl .

+11

All Articles