http://www.perlmonks.org?node_id=11128842

stevieb has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks, I come here seeking help from our mathematicians again, as I'm feeling apathetic today and am having a brain fart moment.

My objective is to find out if my car is parked within a 1.1 metre proximity of where it should be. This will identify whether the vehicle is in my garage or not. I then will read the vehicle's charge level, and using an LED strip on the garage wall, indicate the level on that strip, and if it's below a threshold, sound an audible alarm to remind me to plug the car in to recharge it. I will be using motion and sonar proximity sensors to identify when I've come into the house as to turn the warning off if I don't plug the car in (the car will indicate if the charger is plugged in via my software, and I'll disable the alert when this happens too).

Anyway, with GPS, the fifth decimal place indicates the 1.1 metre area I'm looking to find. My question is, how do I compare the known set location, say 3.1566789, with the actual location of the vehicle, say 3.1565323, and verify whether that they are within at least five decimal places of one another?

I don't know why I'm having this moment, I know it's a silly, easy thing. It'll likely come to me the second I hit submit. I know I could regex the numbers out, but I'd rather have a math calculation as I want to apply it to other areas.

I have no code for this simple example, so I'll just post the following to at least make it perlish.

use 5.10.0; $p=japh;push@a,w();$s=j4;sub n{"8fbac6c6e252"};unshift@a, "b4d6c7ea52a7";$k=crypt($s,$p);$o="aeafa7cfdbd58c";@h= map{sprintf"%x",ord$_}split//,$k;push@a,$o;$a[3]=pop@a; $a[2]=n();sub w{"bcb3d8dec8dd"}$x.=$_ for@a;@b=($x=~m/..?/g); push@z,@h until @z>@b;for(@b){push@japh,hex($_)-hex($z [$n]);$n++;}say map{chr$_}@japh;

Cheers,

-stevieb