The code:
use strict;
my @files = ("08","09");
for my $file (@files) {
my @command = `ls -l|grep $file`;
print "$file $#command\n";
}
works as expected on my box. Your problem is probably in the ".....rest of the script...."
Update:Please create responses, rather than modifying your question. As it stands, your posted code will not work because the $file you pass to your system statement is not a file name. If you swap it for a command element, it still won't work because your ls -l returns more than just file names.