[sf-perl] Opinions on: next LABEL;

Bill Moseley moseley at hank.org
Wed May 11 13:22:47 PDT 2005


On Wed, May 11, 2005 at 11:22:38AM -0700, David Alban wrote:
> I'm in a situation now where I'd like to:
> 
>   FOO:
>   for ( ... ) {
> 
>     for ( ... ) {
> 
>        ...some condition... and next FOO;
> 
>     } # for
> 
>   } # for

Maybe break it into separate functions?  All that indenting makes it
hard to code on your cell phone screen, after all.

sub process_things {

    process_one_thing( $_ ) for @things;

}

sub process_one_thing {
    my ($thing) = @_;

    for ( @$thing ) {

        return if some_condition($_);

        [do stuff]
    }
}


-- 
Bill Moseley
moseley at hank.org



More information about the SanFrancisco-pm mailing list