Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Looping and Grouping: there must be a better way!

by hawtin (Prior)
on Jul 15, 2004 at 07:34 UTC ( [id://374560]=note: print w/replies, xml ) Need Help??


in reply to Looping and Grouping: there must be a better way!

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 }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://374560]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found