I emailed the author of the GPS-Perl module and he suggested to use the alarm function. so I tried it out with the code below but, it still hung on the get_position so maybe perlmonks has a suggestion.
sub gps { my $gps_device; while (1) { goto END if $die == 1; if ($gps_start == 1) { $gps_device = GPS::NMEA->new(Port => $gps, Baud => 4800) o +r die; my $timeout = 5; while (1){ #stops the warnings in the GPS device module local $^W = 0; print "before\n"; eval { local $SIG{ALRM} = sub {die "GPS Device has timed +out\n"}; alarm $timeout; ($ns,$lat,$ew,$lon) = $gps_device->get_position; #warn $@ if $@; alarm 0; }; die if $@ && $@ ne "GPS Device has timed out\n"; if ($@){ print "WARNING\n"; } else{ print "nope\n"; } #($ns,$lat,$ew,$lon) = $gps_device->get_position; print "after\n"; print "$die\n"; goto END if $die == 1; last if $gps_start == 0; sleep 3; } undef $gps_device; } else {sleep 4} } END: }

In reply to Re^2: GPS Widget by deadpickle
in thread GPS Widget 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.