tie @array, 'Tie::File', $fname or die "Can't tie $fname: $!"; my ($first,$last) = @array[0,$#array]; untie @array;