develooper Front page | perl.perl5.porters | Postings from October 2014

experimental mmap snarf (aka slurp) patch

Thread Next
Jarkko Hietaniemi
October 8, 2014 20:12
experimental mmap snarf (aka slurp) patch
Message ID:
I quickly hacked together a patch to try out mmap() in sv_gets()
for the "snarfing" where a filehandle is read wholesale into a scalar.
In Perl parlance this is also known as "slurping".

Practically untested except for the basic scenario:

open my $fh, $fn; my $data = do { local $/; <$fh> }

Handles the (odd) case of not being in the beginning of the handle.
Probably leaks something or does something equally stupid.

Right now I have no time to test/benchmark (and the aggressive caching
by operating systems makes this a very thankless task indeed) but in
case someone else is, please find the patch is attached.  For science.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About