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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.