go ahead... be a heretic | |
PerlMonks |
Most efficient way to load file contents into scalar?by smallwalrus (Initiate) |
on Apr 24, 2009 at 09:28 UTC ( [id://759763]=perlquestion: print w/replies, xml ) | Need Help?? |
smallwalrus has asked for the wisdom of the Perl Monks concerning the following question:
Hi fellow monks,
I've been experimenting with a piece of code here that slurps the contents of a file into a scalar, and found that it runs really slow!
To illustrate, copying the file takes approximately 20 seconds, however loading that entire file into a scalar takes 10 minutes.
The procedure I used was kind of basic though.
do { local $/; <$fh>; }
Is there a faster way to load a file's contents into a scalar?
Back to
Seekers of Perl Wisdom
|
|