opendir(DIRHANDLE, $path) or die "Directory not available"; while ( defined ($filename = readdir(DIRHANDLE))) { @list=(@list,$filename); } @list=sort (@list); @machinelist = grep {/.html/} @list;