in reply to Re: Re: mod_perl: variable $end will not stay shared (nested subroutines problem)
in thread mod_perl: variable $end will not stay shared (nested subroutines problem)
Hm, well, then, here's an alternate approach that does away with a subroutine. I assume the goal is to avoid loading a large file willy nilly into a Perl scalar (because read is already buffered):
Some code (totally off the top of my head, untested, just to give the idea):
# get $start, $end my $bufsiz = 4096; my $total_length = $end-$start; my $chunks = int $total_length / $bufsiz; my $data; if ($chunks) { foreach (1 ... $chunks) { read (FILE, $data, $bufsiz); print $data; } } read (FILE, $data, $total_length % $bufsiz); print $data;
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
|
|---|