Some global variables like $_
, $a
, $b
are effectively predeclared. Therefore, the $a
and $b
variables can be used without extra declarations in a sort
block, where they have the values of two items:
use strict;
my @nums = (1, 5, 3, 10, 7);
my @sorted = sort { $a <=> $b } @nums