In one of the chapters in Mastering Perl, brian d foy shows this snippet from List::Util:
sub reduce(&@) {
my $code = shift;
no strict "refs";
return shift unless @_ > 1;
use vars qw($a $b);
my $caller = caller;
local(*{$caller . "::a"}) = \my $a;
local(*{$caller . "::b"}) = \my $b;
$a = shift;
foreach(@_) {
$b = $_;
$a = &{$code}();
}
$a;
}
I don't understand what's the point of the use vars qw($a $b)
line. Even if I comment it, I get the same output & warnings.