Does calling map { function($_) } <FILEHANDLE>; load the entire file into memory when using perl?
Does calling map { function($_) } <FILEHANDLE>; load the entire file into memory when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes — or at least that’s how I interpret this outcome.
One might wonder whether we run out of memory because Perl is trying to store the output of
map. However, my understanding is that Perl is optimized to avoid that work whenevermapis called in a void context. For a specific example, see the discussion in this question.Perhaps a better example:
Based on the comments, it appears that the question is motivated by a desire for a compact syntax when processing large data.