Your mistake was, that you prepended to filename and afterwards your regex wouldn't match anymore. Here's a fix:
my @files = (); my $dir = $rootPath . $input->param('path'); $dir .= '/' unless $dir =~ m#/$#; opendir (DIR, $dir) or die $!; @files = grep { -f } map { "$dir$_" } grep { !m#^\.# } readdir (DIR); closedir (DIR);
That's the working version of your code. But all hidden files (on *n?x, that is) are removed, too. If you want them to, all you have to do is remove that regex. "." and ".." will get filtered out as well since they are directories, too. At least on my box it worked all fine. That one line should then look like this:
@files = grep { -f } map { "$dir$_" } readdir (DIR);
Regards,
-octo
In reply to Re: Need help with creating a filename only array
by flocto
in thread Need help with creating a filename only array
by S_Shrum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |