in reply to Searching a file system

I believe your problem is related to variable scoping. Try moving all your variables into your sub:
sub walk { my ($file, $prefix);

Unrelated, but you probably want to escape the . in your regex because it has special meaning. Also, there is usually no need to quote a scalar variable:

if ("$file"=~m/.nsf$/){

should probably be:

if ($file =~ m/\.nsf$/) {