Reading Directories 
Author Message
 Reading Directories

Quote:

>I need a script that will search a directory read the name of every file


not sure what you mean with 'search a directory', but this should do the reading
part of your quest:

    opendir(MY_DIR, "/some/directory") || die "huh? $!";

    closedir(MY_DIR);

Quote:
>I've tried and tried with no success
>and had no idea where else to turn.

buy the Camel book (perl.ora.com), it's essential reading for any _serious_ Perl
programmer.

Quote:
>If someone could help me I would be very greatful.  Thank you.

no worries,

Irsan.


#-- The Connection Factory b.v.
#-- http://www.*-*-*.com/



Sat, 25 Nov 2000 03:00:00 GMT  
 Reading Directories

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc,

:I need a script that will search a directory read the name of every file

:and had no idea where else to turn.  

I suggest turning to the manpages, whence cometh thy help.
perlfunc would a good start.

--tom
--
Eighty percent of air pollution comes from plants and trees.
                --Ronald Reagan, famous movie star



Sat, 25 Nov 2000 03:00:00 GMT  
 Reading Directories

Quote:

> I need a script that will search a directory read the name of every file

> and had no idea where else to turn.  If someone could help me I would be very
> greatful.  Thank you.

> Curtis Howard

Have you read any documentation? Check out the FAQs. Better yet, buy the Llama
book.
Hint: Check out readdir() and opendir() functions.

--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)



Sat, 25 Nov 2000 03:00:00 GMT  
 Reading Directories


posted...
|
|>I need a script that will search a directory read the name of every file

|
|not sure what you mean with 'search a directory', but this should do the reading
|part of your quest:
|

[snip]

Or if you only want the files and not the directories too:

#!/usr/local/bin/perl -w
use strict;
  my $dir_name = './dir';
  opendir (DIR, $dir_name) or die "Could not find directory: $dir_name
$!";

  closedir(DIR);
--
Allan M. Due

The beginning of wisdom is the definitions of terms.
- Socrates



Sat, 25 Nov 2000 03:00:00 GMT  
 Reading Directories



Quote:
> I need a script that will search a directory read the name of every file

success
> and had no idea where else to turn.  If someone could help me I would be
very
> greatful.  Thank you.

open(DIR, "/your/directory") or die "Can't open /your/directory";

closedir(DIR);

the grep excludes the . and .. from the list. If you really want files
only, add
use grep(-f $_, readdir(DIR)); instead (. and .. are not files :-)

John

--
------------------------------------------------------------------
C A S T L E  A M B E R      Software Development (Java/Perl/C/CGI)

NEW: http://www.binaries.org/ Guide to Program Binaries & Pictures



Sat, 25 Nov 2000 03:00:00 GMT  
 Reading Directories


Date: Tue, 09 Jun 1998 14:49:04 GMT
Subject: Reading Directories

Quote:
> I need a script that will search a directory read the name of every file

> and had no idea where else to turn.  If someone could help me I would be very
> greatful.  Thank you.

        #!/usr/bin/perl -w
        # usage:  filenames.pl *



        }

That'll do what you want, though that's all it does.  Don't really have
an idea what else you're after.

--
==============================================================================


==============================================================================
           The time for desperation is upon us.  Let's play.
                  First Wizard Zeddicus Zu'l Zorander
==============================================================================    



Sun, 26 Nov 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Reading directories, entering directories, chaning file permissions...

2. Reading Directory Structure

3. help selecting and displaying specific files after reading directory:

4. reading directories

5. read directory question

6. Read Directory

7. Reading Directory

8. Reading Directories w/ Perl

9. Help reading directories and displaying contents

10. Read directory and not files

11. Reading Directories w/ Perl

12. How to read Directory Names

 

 
Powered by phpBB® Forum Software