http://www.perlmonks.org?node_id=155795


in reply to Simplifying repetitive flow structures

The main thing you need to do here is abstract out all the commonalities. From my eyeballing, it seems that the only thing changing is the contents of the Tr data.

Try this

my $td_ref; if ($type eq 'f') { if ($ref->{'pic'}) { $td_ref = [$q->a({href=>"$ref->{'pic'}"}, $ref->{'name'}), $ref->{'phone'}, $ref->{'fax'}, $ref->{'loc'}, $q->a({href=>"mailto:$ref->{'email'}"}, $ref->{'email'} +) ]; } else { $td_ref = ["<LI>".$ref->{'name'}, $ref->{'phone'}, $ref->{'fax'}, $ref->{'loc'}, $q->a({href=>"mailto:$ref->{'email'}"},$ref->{'email'}) ]; } } elsif ($type eq 'c') { # and so on ... } print $q->Tr([$q->td({-bgcolor=>$cellcolor},$td_ref)]);
I also added a bit of spacing for readibility.