in reply to Re3: A matter of style
in thread A matter of style
I don't want this to spiral downwards. What we are talking about here is PERSONAL style. For me its easier to maintain a single entry and single exit. Ill deviate when appropriate, but I tend to try and keep things straightforward. It makes it easier *for me* to maintain and extend my code.# Your code # Pure sub walk_and_do { my $self = shift; my $rc = 1; foreach my $child (@{$self->children}) { $rc = $child->walk_and_do; last unless $rc; } unless ($rc) { $rc = $self->do_my_stuff; } return $rc; } # Same function, single return, just as clear (for me) # ala TIMTOWTDI sub walk_and_do { my($self,$flag,@return); $self = shift; for ( @{$self->childer} ) { (last && $flag = "$_->{err}") unless $_->walk_and_do; } if ($flag) { @return = ('0', "$flag); } else { @return = $self->do_my_stuff || ('0', $self->{err}); } return(@return); }# END sub walk_and_do
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re3: A matter of style
by Anonymous Monk on Feb 15, 2003 at 03:34 UTC | |
by demerphq (Chancellor) on Feb 16, 2003 at 00:05 UTC |