while() { do stuff } # rather than @data = ; for (@data) { do stuff } # pass data to and from subs as a reference (effectively a pointer) # this saves making duplicate copies of data structures my $data_ref = process_data(\@data); sub process_data { my $ref = shift; for (@$ref) { do stuff } return $ref; } #### # this is short but memory intensive do_stuff() if grep { /something/ } @array # compared to this which is faster and uses less memory # but takes 4 lines to write instead of one.... for(@array) { next unless /something/; do_stuff(); last; }