Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Simplifying repetitive flow structures

by admiralh (Sexton)
on Apr 01, 2002 at 16:55 UTC ( #155795=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Simplifying repetitive flow structures
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-09-19 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls