do { opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) { system("/bin/cp -f $dirname/$file malign.top"); system("/bin/cp -f $dirname/$file get-model.top"); system("/usr/local/modeller6v2/bin/mod6v2 $dirname/malign.top"); system("/usr/local/modeller6v2/bin/mod6v2 $dirname/get-model.top"); $m++; } } until ($m==2); #want the whole process to occur twice closedir(DIR); exit;