>From what I understand, each time you perform an operation on <FILEHANDLE>,
you are reading in one line of that filehandle and setting the file up to
read the next line. You are calling the filehandle way too much. For
example:
open(FILEHANDLE,"myfile.txt");
$file1 = <FILEHANDLE>; #gets first line
$file2 = <FILEHANDLE>; #gets second line
$file3 = <FILEHANDLE>; #gets third line
I think what you are trying to do is something like this:
while(<FILEHANDLE>){
$myVariable .= $_;
}
Personally, I find it easier to use this method:
@lines = <FILEHANDLE>;
This reads the entire file into the array @lines with one line per element.
This way when I want to print it back out or perform some operation on it, I
can do it like this:
print @lines;
or like this:
foreach $line(@lines){
print $line;
}
-----Original Message-----
From: Jarrod Ramsey [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 3:23 PM
To: [EMAIL PROTECTED]
Subject: File I/O Question
This is a pain for me to deal with, maybe its my method or the way I'm
reading the file, but when I open a file, it reads only every 4th line. The
way I thought it was set up, it should only read one line at a time. Please
look at the code below and help me out if you can.
I've tried it several ways, and this one happens to be the last one I tried.
Any help would be useful.
( my(@allFiles) = readdir(DIRHND) ) || ( LogEntry(statslog, "Couldn\'t read
$userpts: $!") );
foreach $file (@allFiles) {
my($sBody); my($a);
$file = "$userpts\\$file";
print "$file\n";
next unless ( open(FIL, "$file")); ## I watched the code execute
and this statement actually gets the first line.
$sRecp = <FIL>; ## whereas this one gets the
second line.
while (<FIL>) { ## this one the third
$sBody .= <FIL>; ## this one the
fourth
}
print $sBody;
chomp($sRecp);
close(FIL);
}
closedir(DIRHND);
Thanks
-jr
**********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the individual or entity to
whom they are addressed. If you have received this email
in error destroy it immediately.
**********************************************************************
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
--------------------------------------------------------------------------------
This email may contain confidential and privileged
material for the sole use of the intended recipient.
If you are not the intended recipient, please contact
the sender and delete all copies.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin