opendir (CDIR, $cfgFilesDir) or die; my $file; my $thr; while ($file = readdir(CDIR)) { if ($file =~ /.+?\.properties/) { $thr = threads->create(\&sendRequest, $file, 'localhost', $peerPort ); } } closedir (CDIR); #### while( my $file = <*.properties> ) { ## Check the glob matches your files! my $thr = threads->create(\&sendRequest, $file, 'localhost', $peerPort ); }