in reply to How do I read all the file names of a directory into an array?

Use backticks (`) to execute a shell command and capture its output (see the perlop manpage):

my @filename = split("\n", `ls`); my $total = scalar(@filename);

This would replace everything after the line "use strict;" and before "$error = ...".

Note you can also replace your for-loop with a foreach which would mean you wouldn't need $total any longer. See perlsyn.

  • Comment on Re: How do I read all the file names of a directory into an array?
  • Download Code