How can I loop through files in a directory in Perl?
file, perl
Solution
#!/usr/bin/perl -w
my @files = <*>;
foreach my $file (@files) {
print $file . "\n";
}
Where
@files = <*>;
can be
@files = </var/www/htdocs/*>;
@files = </var/www/htdocs/*.html>;
etc.
Problem
Possible Duplicate: How can I list all of the files in a directory with Perl? I want to loop through a few hundred files that are all contained in the same directory. How would I do this in Perl?