in reply to Re^7: local() for scalar file slurping
in thread local() for scalar file slurping

You're misundersanding. The entire value is stored at once in a temporary variable known only on a padlist. The next operation, the scalar assignment, should utterly consume the temporary value during its use instead of making a copy just for it's own purposes. There should only be one copy of the data during this entire process. This is a perl5 thing, not a perl6 thing. I'm only speaking about perl5 internals.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^9: local() for scalar file slurping
by rodion (Chaplain) on Jul 31, 2006 at 19:28 UTC
    Your quite right, I got muddled thinking about the records coming back and being passed up, but the whole point of the OP was to put the entire file into a scalar. Lists, lazy or otherwise, have nothing to do with it.

    Let's see if I've managed to get this through my somewhat thickening skull. (And to move down a level of abstratction).

    • The file is opened within the do{} loop, and records are transfer to a temporary scalar variable
    • The file finishes. The do{} loop passes the temporary back to the assignment
    • The compiler has recognized (using the code tree?) that the temporary is only going to the assigned to a variable, $foo, and the $foo SV is set to point to the data from the temp SV; the temp SV is now available for the next use. Thus the data exists only once.

    At least that's the way it's supposed to work, so the additional memory usage observed by Grandfather shouldn't happen.

    Let me know if I've gotten this significantly wrong. (And thanks for the corrections, and your patientce when I got lost.)