blnukem said:
opendir DIR, "../";
@htmlpages = grep /\.html$/i, readdir DIR;
print "@htmlpages";
OK, if you're wanting to search recursively, you need to make your code
recursive too. Here is an example (inspired by an example in the book "Perl
for System Administration" from O'Reilly) that keeps track of where you
started and then keeps running the 'scan' sub routine from within itself.
Any files ending in '.html' are pushed into the @htmlpages array.
I recommend that book by the way
------------------
#!/usr/bin/perl -w
use strict;
use Cwd;
my @htmlpages;
sub scan{
my $currentdir = shift;
my $startdir = &cwd;
chdir($currentdir);
opendir(DIR, '.');
my @files = readdir(DIR);
closedir(DIR);
foreach (@files){
next if /^\./;
if (-d $_){
&scan($_);
next;
}
if (/\.html$/) {
push (@htmlpages, $_)
}
}
chdir($startdir);
}
&scan('.');
print @htmlpages;