hi,

Is it possible to read 2 or more files and getting data out of them simultaneously? can I know the perl format for that

Sure,
open F1,...
open F2,...

then
aLine = <F1>
anotherLine=<F2>

and so on

sorry,

What i meant was to open more than 2 files.. say 1000 files within a while loop and then retrieve some data from those files one at a time...for example to open a directory with 1000 files and then read those files one at a time....

is this possible? wat is the syntax for this kind of a problem

Open each one of them in turn?
Or open many of them at once?
- Because there are limits to how many files you can have open at the same time

If you list the files on the command line, then
while ( <> )
will process each file in turn

Yes, I meant each file in turn.
For ex: if a directory has 100 or more files, then u write the syntax:

open (DIR, "path/name of directory");


then you read the directory within a while loop and read each file.
I would like to know how to open one file at a time,read them, do something with that file and create an output file within the program itself. is this possible. I dnt know the syntax for this, where in within the while loop after each file, it automatically prints the output to an output file, so as and when a file is read, it conducts a process and prints the output to an output file. this iteration shud take place for probably 1000 files in a directory. is this possible?... syntax???

opendir (DIR, "path/name of directory") or die "$!";
while(my $file = readdir(DIR)) {
   next if ($file eq '.' || $file eq '..');
   open (my $FH, "path/name of directory/$file") or print "$!\n";
   while (my $line = <$FH>) {
      do something with $line
   }
   close $FH;
   }
}
closedir DIR;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.