Greetings.
So if you do this:
my @foo = @{[`cat very_large_file`]}[0..3];
does Perl temporarily grab enough memory to store
very_large_file, then slice the first four lines?
Or does it abandon the
cat process once it has what it needs? And if it does this, does it kill it or just leave it running to completion, ignoring its output?
To test this, I devised an experiment replacing
cat... with a command that just kept generating output indefinitely:
#!/bin/bash
while :; do
rand -N 100
done
The result seems to be that Perl keeps gobbling memory as long as the process generates output, then when the process ends it returns the appropriate slice.