Yes, but if you read a whole file into an array, in spite of such optimisation being reasonable at that point, Perl won't reorganise your code to minimise memory usage, nor does it provide hooks to insert your code per iteration of such optimisation.