473,587 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read a directory and it's files

2 New Member
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 1885
3,509 Recognized Expert Moderator Specialist
Please post the code that you have tried thus far and we will guide you to learning how to do this.


Oct 14 '10 #2
2 New Member
Expand|Select|Wrap|Line Numbers
  1. opendir MYDIR, "c:\data";
  2. @contents = readdir MYDIR;
  3. closedir MYDIR;
  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);
  5. foreach $file (@files) {
  6.    print $file;
  7. }
Oct 16 '10 #4
589 Recognized Expert Moderator Contributor
How can I read the files in blocks of 64 KB?
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

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 people can modifi the ini. an example is the program mysql (meightbe someone has seen it) that's exatly wath i'm trying to do.
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 only 2 File buttons with corresponding text fields. The actual guts of the program is a C file that accepts 2 file names as arguments and reads from...
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 identical with which. Write a program that prints out which file are redundant copies. Here's the spec. -------------------------- The program is...
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>
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 / Bluetooth / Infrared. May I ask does serial port equal to com port? The program needs to read and write data of the smart card which places on top...
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 run out of memory). I will retrieve from the file later. What I do is use streamwriter.write and streamreader.read
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 I do? I've configured tap0 with debian:/home/fabrizio# tunctl -u root Set 'tap0' persistent and owned by uid 0 so I don't have the device...
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
by: leninbecse | last post by:
How to Write the Read-only file in java?
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.