Help with directory listing: filenames or directories 
Author Message
 Help with directory listing: filenames or directories



Quote:
>I am using the following code to get the entries in a directory:

>    $DIR_NAME = "/home/myacount";
>    opendir(MYDIR, $DIR_NAME);

>    close(MYDIR);





  {
    $pathName = "$DIR_NAME/$file";

    print "$pathName is a directory\n" if -d $pathName;
  }

Hope this helps,

Mike

--
Mike Stok                        | The "`Stok' disclaimers" apply.


http://www.{*filter*}com.net/~stok/   | The inevitable WWW page (?)



Sat, 28 Feb 1998 03:00:00 GMT  
 Help with directory listing: filenames or directories

Quote:

>I am using the following code to get the entries in a directory:

>    $DIR_NAME = "/home/myacount";
>    opendir(MYDIR, $DIR_NAME);

>    close(MYDIR);





  {
    print $file, " - ";
    print "Plain File"    if -f $file;
    print "Directory"     if -d $file;
    print "Symbolic link" if -l $file;
    print "Named pipe"    if -p $file;
    print "Socket"        if -S $file;
    print "\n";
  }

Of course, $file would have to be the full path name to the file, unless the
files are in the current directory.

These are just some of the file test operators.  See page 84 of the Camel book,
or the perlfunc man page.

--

Technical Consultant | GCS/E d++(pu) s+: a C++++ US+++$> P+> L+> !E W+ N+++
Datronics inc.       | !o !K w--- M-- V-- PS+++ PE Y+ PGP t+++ 5 X+> tv+
                     | b++++ DI+++ D++(+++) G e++> h---- r+++ y++++



Sat, 28 Feb 1998 03:00:00 GMT  
 Help with directory listing: filenames or directories
I am using the following code to get the entries in a directory:

        $DIR_NAME = "/home/myacount";
        opendir(MYDIR, $DIR_NAME);

        close(MYDIR);



--
Constantinos Phanouriou

WWW  : http://csgrad.cs.vt.edu/~phanouri/



Sat, 28 Feb 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. listing of Filenames under a directory

2. Help!Exclude a directory from a directory search!

3. HELP: remove directory and symbolic link to directory

4. Help: perl script to list only directories

5. Help with listing files in a directory

6. Help on recursive directory listing

7. Help!! listing all files in a directory recursively

8. Help for listing directory contents

9. Directory listing query with Net::FTP::list

10. Directory listing query with Net::FTP::list

11. Need CGI script to search filenames withing a directory

12. renaming filenames when they exists in destination directory

 

 
Powered by phpBB® Forum Software