in reply to Problems creating sub's

In the second snippet, do you really mean this to be the first line of goodDir?

my $filename = $_;   # file we're testing

Or do you mean one of these instead:

my $filename = shift; my ($filename) = @_; my $filename = $_[0];