Perl 5 has dynamic scoping for backward compatibility with Perl 4, which had only dynamic scoping, and not only that, it botched it so that this code didn't work right:
sub greet {
local ($who) = @_;
print "hello, $who\n";
}
$who = "world";
&greet($who);
This would print, "hello, " with a newline, due to a design bug called "variable suicide", which has been fixed in newer Perls.Needless to say, this made the extract-subroutine refactoring quite a bit more trouble in Perl 4.