469,347 Members | 10,318 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,347 developers. It's quick & easy.

How to read a directory and it's files

I want to implement a Perl Program that takes a directory path, ex (d:\programs) as an INPUT and this directory could have multiple files for this program lets say 5 files (doc1, doc2, doc3, doc4, and doc5). This program should print the average time to open and read all these five files into OUTPUT. How can I read the files in blocks of 64 KB?
Oct 14 '10 #1
4 1693
numberwhun
3,503 Expert Mod 2GB
Please post the code that you have tried thus far and we will guide you to learning how to do this.

Regards,

Jeff
Oct 14 '10 #2
Expand|Select|Wrap|Line Numbers
  1. opendir MYDIR, "c:\data";
  2. @contents = readdir MYDIR;
  3. closedir MYDIR;
  4.  
  5. foreach $listitem ( @contents )
  6. {
  7.   print $listitem;
  8. }
But I am not sure if I am going correct way and kind of lost
Oct 14 '10 #3
Expand|Select|Wrap|Line Numbers
  1. opendir(DIR,"c:/data") or die "Error: $!";
  2. @files = readdir(DIR);
  3. closedir(DIR);
  4.  
  5. foreach $file (@files) {
  6.    print $file;
  7. }
  8.  
Oct 16 '10 #4
RonB
589 Expert Mod 512MB
How can I read the files in blocks of 64 KB?
See:
perldoc -f sysopen
perldoc -f sysread
Oct 18 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Gurk | last post: by
3 posts views Thread by Simon Wigzell | last post: by
2 posts views Thread by Andrea Bauer | last post: by
6 posts views Thread by fabrizio | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.