Perl question.



  • <font size="3">Since everyone on here seems to think that they're the best programmers in the world I'd like to see what people come up for with this problem. </font>

    <font class="fixed_width" face="Courier, Monospaced" size="3">A while ago while I was in the Army I co-wrote an exercise SIGINT </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> generator with a friend. We made a mess of a few functions called </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> VaryLat and VaryLong. The functions basically took in two arguments: a </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> Latitude or Longitude and an amount to vary it by(in seconds). The </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> second parameter could be any number positive or negative. The real </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> issues started rising when we figured out that crossing over either the </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> 90' mark or the 180' mark was throwing off our numbers. The functions </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> turned out to be very long seeing as how neither of us was very </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> experience with Perl at the time. I wish I had the code to post to show </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> how messy this thing was but seeing as how it was on a Top Secret//SCI </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> machine security protocols made if impossible to bring a copy of this </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> source home at the time. Basically I was wondering if anyone else has </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> had this particular problem and came up with a good solution. It's been </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> bugging me ever since I wrote the stupid code. The function prototype </font>
    <font class="fixed_width" face="Courier, Monospaced" size="3"> was something like this: VaryLat($theLatitude,$varyAmount).</font>
    <font class="fixed_width" face="Courier, Monospaced" size="3">So if you had VaryLat(101010N,30) it would return 101040N. </font>


  • @bugmenot said:

    <FONT size=3>Since everyone on here seems to think that they're the best programmers in the world I'd like to see what people come up for with this problem.</FONT>

    <FONT face="Courier New" size=6>STOP.  LOOK.  LISTEN.</FONT>



  • @emptyset said:

    @bugmenot said:

    <FONT size=3>Since everyone on here seems to think that they're the best programmers in the world I'd like to see what people come up for with this problem.</FONT>

    <FONT face="Courier New" size=6>STOP.  LOOK.  LISTEN.</FONT>

    [:|]



  • If your problem was getting 90 seconds to carry over into 1 minute, 30
    seconds, there's a straightforward mathematical way to do it:



    $Minutes += trunc( $Seconds / 60 );   $Seconds %= 60;

    $Degrees += trunc( $Minutes / 60 );   $Minutes %= 60;



    or perhaps more obviously with a loop:





    ----

    oops, I forgot the case when you're subtracting:



    while( $Seconds < 0 ) { $Seconds += 60;  $Minutes--; }

    while( $Minutes < 0 ) { $Minutes += 60; $Degrees--; }



    that should do it.







Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.