Because when Perl is parsing your code, it hasn't completed the definition of the
walk() function, so it doesn't know the bareword
walk is a function. If you just say:
sub walk;
sub walk { ... }
then the code will work as you'd like.
japhy --
Perl and Regex Hacker