For the hundred goals, you display 'array.bmp' if the match fails and an image specified by a name in an array if the match succeeds. Setting the appropriate value into a local variable allows a single print statement.
For each of the hundred goals, you have a different set of coords. Set up an array with the values stored in inner arrays, and then format the appropriate set into a variable for the print statement. If you can have an undef or empty first element in @graph_links then you could use $goal instead of $goal-1 in that line as well.
Sample code follows ...
@coords = ( undef, # use a null $coords[0] [13,9,6], [184,9,6], ... ); for my $goal ( 1..100 ) { for my $well ( @existing_wells ) { my $img = ( $well == $goal ) ? $graph_links[$goal-1] : "array.bmp"; my $coords = join ',', @{coords[$goal]}; print qq(<area href="http://cgi-bin/$img" ALT="" shape="circle" coords="$coords">); } }
But if you have a 50 elements in @existing_wells you wind up with 5000 lines of output of about 75 characters each, or about 375,000 characters just for this section. Is there a different way of dealing with this?
In reply to Re: minimising repetitive if-elsing
by TomDLux
in thread minimising repetitive if-elsing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |