chdir($workdir); foreach ($files) { workOnFile(); ## should have $_ as an arg, shouldn't it? }