Subject: | Geo::Calc::XS midpoint_to returns different results in debugger |
The method midpoint_to returns different results when run with and without the debugger enabled.
Without the debugger:
$ perl run_with_debugger.pl
$VAR1 = {
'lat' => '51.512438',
'lon' => '-0.133619'
};
With the debugger:
perl -d ~/run_with_debugger.pl
Loading DB routines from perl5db.pl version 1.37
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(/home/davidl/run_with_debugger.pl:14):
14: my $midpoint = Geo::Calc::XS->new(lat => 51.508348, lon => '-0.143719', units => 'm')->midpoint_to(
15: {lat => 51.516528, lon => '-0.123518'});
DB<1> c
$VAR1 = {
'lat' => '51.5',
'lon' => '-0.1'
};
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
The script is attached. I encountered this bug with Perl v5.16.3 on Linux compiled without threads. I also reproduced this bug with Ubuntu's packaged Perl v5.18.2.
Subject: | run_with_debugger.pl |
#!/usr/bin/env perl
# Run this with "perl", and then with "perl -d", and you'll notice a bug that
# the results are not the same! The latter trims the lat/long coordinates to
# one decimal point.
use strict;
use warnings;
use utf8;
use Geo::Calc::XS;
use Data::Dumper;
my $midpoint = Geo::Calc::XS->new(lat => 51.508348, lon => '-0.143719', units => 'm')->midpoint_to(
{lat => 51.516528, lon => '-0.123518'});
print Dumper($midpoint);