my @lines = read_file( ... ); # note copying, rather than passing a ref for ( @lines ) { .... }