in reply to Re: Attempt at eliminating a global variablein thread Attempt at eliminating a global variable
btw,
sub scope_test{ my @data_in = <DATA>; my @data_out; for (0..$#data_in){ call_back(\@data_out, $data_in[$_]); } print "$_" for @data_out; } [download]
can be simplified to
sub scope_test{ my @data_out; while (<DATA>) { call_back(\@data_out, $_); } print "$_" for @data_out; } [download]
or even
sub scope_test{ my @data_out; call_back(\@data_out, $_) while (<DATA>); print "$_" for @data_out; } [download]