in reply to New to Perl: Finding files on FTP
You don't even need to change the directory. Give this a shot -- it stores the contents of a directory and removes non-files
my $dir = '/genomes/Bacteria'; # use single quotes where possible, e.g., no var or \n # it's a tiny bit faster ## get the contents of a directory my @dir_listing = <$dir/*>; ## note: using <$dir/*/> would find all the directories ## removes . and .. while ($dir_listing[0] =~ /^\.+$/) { shift @{$dir_listing}; } ## removes all directories my @files_found = map { (-d $_) ? () : $_ } @dir_listing;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: New to Perl: Finding files on FTP
by Klaas (Initiate) on Mar 14, 2012 at 18:03 UTC | |
by runrig (Abbot) on Mar 14, 2012 at 20:29 UTC | |
by Klaas (Initiate) on Mar 15, 2012 at 10:58 UTC | |
by muppetjones (Novice) on Mar 14, 2012 at 21:00 UTC |