When I run this code snippet, the program is supposed to open waytemp, read in the data, then replace NEW with OLD on the file top and reprint the data. The problem I am encountering is that the program is not printing the data to the waytemp file, the second time around. Im suspecting that it is not entering the for loop or encountering an error when it enters it. I think I need some fresh eyes to look at the code.
#!/usr/bin/perl -w use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use threads; use threads::shared; my $die: shared = 0; my $verification_control: shared = 0; my $waytemp_local: shared = 'C:\Users\deadpickle\Desktop\files\waytemp +'; my $wayfinal_local: shared = "/home/deadpickle/Desktop/project_downloa +ds/wayfinal"; my $thread_verification = threads->new( \&verification); my $timer2 = Glib::Timeout->add(100, \&messagedialog); my $window = Gtk2::Window->new('toplevel'); my $button = Gtk2::Button->new( 'GO'); $window->signal_connect(delete_event => sub { $die = 1; $thread_verifi +cation->join; Gtk2->main_quit}); $button->signal_connect('button-press-event' => sub { $verification_co +ntrol = 1}); $window->add( $button); $window->show_all; Gtk2->main; sub verification { while(1){ if ( $die == 1 ){ goto END }; if ( $verification_control == 1 ){ for(;;){ print "GO\n"; my $count; if($die == 1){ goto END }; #open waytemp and load the waypoint locations then clo +se the file; the values will remain in the variables for later use open TEMP, '<', "$waytemp_local" or die; my @temp = <TEMP>; print "@temp\n"; chomp @temp; close TEMP; #count the lines in the waytemp file; disregard the fi +rst line since it is just the "time" stamp my $line = @temp - 1; #check if the waytemp file is NEW; checks only the fir +st line in the file if ( $temp[0] eq 'NEW') { #print the waypoints to the waytemp file; add OLD +to the top open TEMP, '>', "$waytemp_local" or die; print TEMP "OLD\n"; for ( $count = 1; $count >= $line; $count++) { print TEMP "$temp[$count]\n"; } close TEMP; #run the dialog that verifies the waypoints; needs + user input $verification_control = 2; if ( $verification_control == 2) { for (;;) { #if 'yes' if ( $verification_control == 3) { last} #if 'no' if ( $verification_control == 4) { goto NO +} } } #upload the new wayfinal file copied from the new +waytemp open FINAL, '>', 'C:\Users\deadpickle\Desktop\file +s\wayfinal' or die; for ( $count = 1; $count >= $line; $count++) { print FINAL "$temp[$count]\n"; } close FINAL; NO: } $verification_control = 1; } $verification_control = 0; } } END: } #Message Dialog box that asks to verify the new waypoints recieved fro +m the server sub messagedialog { #Run the message dialog if the waytemp file is stamped with a "NEW +" if( $verification_control == 2) { my $messagedialog_verification = Gtk2::MessageDialog->new( und +ef, 'destroy-with-parent', 'question', 'yes-no', "Verify waypoints?") +; $messagedialog_verification ->set_position( 'center'); my $response = $messagedialog_verification->run; #if the file is verified $verification_control = 3 if $response eq 'yes'; #if the file is not verified $verification_control = 4 if $response eq 'no'; $messagedialog_verification->destroy; } return 1; }

In reply to Gtk2: not entering for loop 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.