chdir($path) or die "foo error message\n"; #now do some foo with $filename in this directory