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