in reply to Using READDIR runs out of memory
To get only names ending in .html, I would do this: my @jrnFiles = grep {/\.html$/} readdir DIR; Perl should be fine with 1 million files in the directory.