I'm storing all the warning points in the "@warningPoints" array with WPLong the first element and WPLat the seconds, this repeats itself through the array. Any suggestions on how to make this script take multiple warning points?

How about using a hash of hashes? It would fit better with your needs. You can use numbers as the keys, which will be considered strings by perl for that purpose anyway.

%warningPoints = ( 1 => { WPLong => 10, WPLat => 20, }, 2 => { WPLong => 30, WPLat => 40, }, ... );

To get multiple latitude and longitude values, you can create as many text fields as needed in your form, all named latitude or longitude, depending on what they expect for a value. The param() method will then return a list consisting of all the corresponding values. An example:

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use CGI; my $q = new CGI; print $q->header(), $q->start_html(); print $q->start_form(); print $q->textfield(-name => 'Latitude', -size => 10, -maxlength => 10 +, -override => 1); print $q->textfield(-name => 'Longitude', -size => 10, -maxlength => 1 +0, -override => 1); print $q->textfield(-name => 'Latitude', -size => 10, -maxlength => 10 +, -override => 1); print $q->textfield(-name => 'Longitude', -size => 10, -maxlength => 1 +0, -override => 1); print $q->submit(-name => 'choice', -value => 'Submit'); print $q->end_form(); my $choice = lc($q->param('choice')); if ($choice eq 'submit') { my @lat = $q->param('Latitude'); my @long = $q->param('Longitude'); print $q->pre(Dumper(\@lat)); print $q->pre(Dumper(\@long)); } print end_html();

The coordinates of the first point would then be ($long[0], $lat[0]), and so on for all points.

One good thing about this method is that you can add text fields with the help of some JavaScript, not having to submit the form each time. One bad thing is you have to use the -override switch to avoid the form, as well as the user, from being slightly confused in case you print it after submission.


In reply to Re: Need Help With Writers Block by Fang
in thread Need Help With Writers Block by awohld

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.