Is there some reason for not putting the "grouping" code in a subroutine?
My personal bias would be to scope the array over a pair of subroutines that playe with it
... if ( @sub_list > 1 ) { # maybe lots of code here to build the record, # using all those attributes... add_record(# some record ); } ... if ( @sub_list > 1 ) { # maybe lots of code here to build the record, # using all those attributes... add_record(# some record ); } .... { # Private scope for various things my @complete_list = (); sub add_record { my($record) = @_; ... push @complete_list, $record; } sub find_record { my($index) = @_; # Do some checking for validity return $complete_list[$index]; } # End the private scope }
In reply to Re: Looping and Grouping: there must be a better way!
by hawtin
in thread Looping and Grouping: there must be a better way!
by edan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |