I might not have expressed myself correctly, but I was only trying to say that, since $ref and @head are never changing in the presented code, each time through the loop, the values of @aa will clobber the previously recorded ones, so that the loop is in effect useless, it would be faster to go straight to the last line of the file, split it and run the discussed command only once. Example under the Perl debugger:
DB<1> @head = qw 'foo bar baz'
DB<2> @{$ref}{@head} = qw /one two three/;
DB<3> x $ref
0 HASH(0x8032f9b8)
'bar' => 'two'
'baz' => 'three'
'foo' => 'one'
DB<4> @{$ref}{@head} = qw /four five six/;
DB<5> x $ref
0 HASH(0x8032f9b8)
'bar' => 'five'
'baz' => 'six'
'foo' => 'four'
DB<6>
The assignment of line 4 is clobbering what was previously in the hash referenced by $ref. It does not make sense to do that in a loop, since only the last assignment of the loop is useful.
Or the real code is different, in which case it might be useful to see the real code.