Hi deadpickle,

The reason you're getting 1 2 again, instead of 5 6, can be quickly visualized with the following 2 modifications:

First, add Data::Dumper to the top of the program:

use strict; use warnings; use Data::Dumper; # Add this line

And then display what's happening in the subroutine compile by adding a printf near the end:

sub compile{ $all = $waybox->index('end'); print "$all\n"; for(my $num = 1;$num <= $all;$num++){ my $new = $num-1; my $sel = $waybox->get($new); print "TFD> sel <$sel>\n"; chomp ($sel); push(@latlong, $sel); } # liverpole -- Add a "Temporary for debug" print statement printf "TFD> latlong => %s\n", Dumper(\@latlong); $go = 1; }

What you'll then see, following your instructions above, is that when you connect the first time (with points "1 2" and "3 4"), you get the expected:

TFD> latlong => $VAR1 = [ '1 2', '3 4' ];

But the second time you connect, after adding "5 6", you get:

TFD> latlong => $VAR1 = [ '1 2', '3 4', '1 2', '3 4', '5 6' ];

So you probably just need to clear the points from the @latlong, perhaps at the end of the block in sub sftp:

if ( $go == 1 ){ # ... @latlong = ( ); }

Note, however, that you may need to lock the shared data structure @latlong, both in the parent thread and the child, wherever it is being changed (unless your flag $go is correctly handling any race conditions).

Update:  Looking at some of your code more in-depth, you may want to put a delay everywhere you have a tight loop, so that it doesn't hog cpu time.  For example:

for(;;){ if( $progress == 0){last} # Pause for 1/10th of a second to be a good citizen select(undef, undef, undef, 0.1) }

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: Waypoint file generator wont post right points by liverpole
in thread generate file from a listbox by deadpickle

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.