I am having trouble in dealing with file handle Chunk issue.
Here is what I did:
Linux/Apache/perl 5.6/Mod_perl.
When you click a link, a perl code is invoked which parses a list of files in a loop.
A piece of code list below (very simple):
What I expect is something like this:
However, the actual log is like this:
That means the whole file was treated as one line -- all line feeds are ignored!
Certainly, the actual code was quite complicated and the piece shown above is very much simplified. I tried to run the simplified piece from cmdline and it works just fine.
Could someone here tell me
1) how to deal with the file handle CHUNK problem?
2) under what circumtances, could this problem happen?
Many thanks!!!
Here is what I did:
Linux/Apache/perl 5.6/Mod_perl.
When you click a link, a perl code is invoked which parses a list of files in a loop.
A piece of code list below (very simple):
Code:
foreach my $fn (@fileList) {
parseFile($fn);
}
sub parseFile {
my $file = $_[0];
open(FH, "$file") || die;
my $i = 0;
while(FH) {
my $len = length($_);
warn "\$i = $i, \$len = #$len#";
$i++;
}
close(FH);
}
What I expect is something like this:
Code:
[Fri Dec 8 11:12:27 2006] null: $i = 0, $len = #20# at {$somepath}/myperl.pm line 3862.
[Fri Dec 8 11:12:27 2006] null: $i = 1, $len = #42# at {$somepath}/myperl.pm line 3862.
......
......
However, the actual log is like this:
Code:
[Fri Dec 8 11:12:36 2006] null: $i = 0, $len = #258476# at {$somepath}/myperl.pm line 3862, [b]<INFILE> chunk 1[/b].
That means the whole file was treated as one line -- all line feeds are ignored!
Certainly, the actual code was quite complicated and the piece shown above is very much simplified. I tried to run the simplified piece from cmdline and it works just fine.
Could someone here tell me
1) how to deal with the file handle CHUNK problem?
2) under what circumtances, could this problem happen?
Many thanks!!!