-   Programming (
-   -   HELP: PERL script to retrieve file listing (

xboxter 05-18-2005 09:24 PM

HELP: PERL script to retrieve file listing

I am trying to write a portion of a perl script where I want to output the file listing of a directory, but only outputting files and not showing directories. Is this possible to do in PERL? If it helps, I am also using Perl's NET::FTP class.

Thanks in advance,


keefaz 05-19-2005 03:45 AM

If you want just to see regular files, try :



my $dir = '/etc';

opendir MYDIR, $dir or
    die "Can't open $dir: $!";

while( my $file = readdir(MYDIR) ) {
    next if not -f "$dir/$file";
    print "filename: $file\n";
    print "full path: $dir/$file\n\n";

closedir MYDIR;

I use the -f test to check if the file is a regular file

xboxter 05-19-2005 09:19 AM

Thanks alot keefaz, It worked great.


All times are GMT -5. The time now is 03:24 AM.