473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 let’s 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 1879
numberwhun
3,509 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

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

Similar topics

8
by: Gurk | last post by:
hi the settings of my program are stored in an ini file, is there a simple way to open the file in some textbox, ore a betteer soutable box. i also want it to be able to resave the ini so...
3
by: Simon Wigzell | last post by:
I recently wrote a program with MS Visual Studio C++, sent it off to the client where it didn't run, after some probing I discover they are on a Mac! My program is a MSF interface that is really...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
2
by: Andrea Bauer | last post by:
Hallo, wie kann ich so eine Datei unter .Net schreiben C++ oder C#. Bitte mit Funktionsaufrufen. Vielen Dank. Grüße Andrea <Product> <ProgramNumber>2</ProgramNumber>
0
by: Tom | last post by:
I am new to hardware programming. I need to write a program for reading data from Card Reader which connects to the PC windows 2000/XP OS through Interfacing The Serial / RS-232 Port / USB /...
1
by: tim | last post by:
I have a multi-dimensional byte array, private someArray(,,) as byte and it's huge redim someArray(100,640,480,3) after populating the array, I write it to a text file to save it. (so I don't...
6
by: fabrizio | last post by:
I've to write an applications which emulates the network, so this application must write and read all the data passing on network interfaces like eth0 and tap0(virtual ethernet interface). How can...
0
by: psbasha | last post by:
Hi, Is there any module available to write and read a XML file using Python? Links for the material will help me. Thanks in advance PSB
3
by: leninbecse | last post by:
How to Write the Read-only file in java?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.