in reply to match names

To me, chdir is just Bad (notice the capital 'B').
How about something like
my $tdtRoot = 'c:/tdt/src'; if (opendir (DIR, $tdtRoot)) { while (my $fileName = readdir (DIR)) { if ($fileName =~ m/\.tdt$/) { system ("$BASEDIR/nbsstools/tdtgen/bin/tdtgen $tdtRoot/$fileName +"); } } closedir (DIR); }