########################################################################### # LOAD RESOURCES # ########################################################################### if (-d $CurrentDirectory.'/Resources') { opendir (DIRECTORY, $CurrentDirectory.'/Resources'); @Directory = readdir(DIRECTORY); closedir (DIRECTORY); shift(@Directory); shift(@Directory); RemoveDirectories: for ($DirectoryEntry = 0; $DirectoryEntry < @Directory; $DirectoryEntry++) { if (-d $Directory[$DirectoryEntry]) { splice(@Directory,$DirectoryEntry,1); goto RemoveDirectories; } } } ################# # this could be a subroutine that gets the simple Resource files # underneath the specified directory # # *** untested *** but the idea is sound.... my @file_paths = get_resource_files ($current_directory); print join ("\n",@file_paths),"\n"; sub get_resource_files { my $directory = shift; opendir (my $fh_resource_dir, "$directory/Resources") or die "$directory/Resources does not exist $!"; # grep is a "filter" function. Only an array of simple file # names are returned. There are things that are not a directory # but are also not a simple file. These are weird, but they exist. # Use the -f test for simple files. # # readdir() only returns simple file names, not the full path # I guess you would really want the full path to the files? my @file_paths = map{"$directory/Resources/$_"} grep {-f "$directory/Resources/$_"} readdir $fh_resource_dir; return @file_paths; # the directory file, handle $fh_resource_dir is automatically # closed when my $fh_resource_dir goes out of scope. # A "barewword" like DIRECTORY has global package scope }