Don't forget however that creating the array by whichever method is an overhead.

The array will be returned to the main script which will need to iterate it to do the real work.

Moving the file read into the main script rather than using a UDF will avoid the overhead in both CPU and memory - the cost of maintaining an additional 8MB local variable data in memory should not be taken lightly!

It is a balance in the end of course.

As a one-off admin task the simplicity and ease of using one of these UDFs far outweighs the disadvantages.

Should you be writing a user activated script to be deployed on (say) multi-user Citrix or Terminal Server environments you would be more conservative about how resources are used.