$gap = "$gap.00";
####
use Math::BigInt;
use Math::BigInt ':constant';
####
$mins = tdiff($now, $then);
####
#!/usr/bin/perl
use strict;
use IntTest;
use Time::Local;
my ($mins, $days, $now, $then, $elapsed);
($now, $then) = @ARGV;
if (!$now) {$now = "2013-0923";}
if (!$then) {$then = "2013-1023";}
$mins = tdiff($now, $then);
#Removable code #1
# $mins = "$mins.00";
#Gap is the difference in minutes, so change it to days:
$days = ($mins / 60) / 24;
#Divide by days in a year so it can be used in interest formula
$elapsed = $days/365;
print "Now: $now, Then: $then, Minutes: $mins, Days: $days, Elapsed: $elapsed\n";
####
#
package IntTest;
#These two lines are the culprit. Without them, it's fine
use Math::BigInt;
use Math::BigInt ':constant';
use Time::Local;
use Exporter;
use strict;
BEGIN {
use vars qw(@ISA);
@ISA = qw(Exporter);
our @EXPORT = qw(tdiff tconvert);
}
sub tdiff {
my ($now, $then, $diff);
($now, $then) = @_;
if (!$then) {
$then = $now;
$now = tconvert();
}
$now = tconvert($now);
$then = tconvert($then);
$diff = int(($then - $now) / 60);
return $diff;
}
#Take time and dates in the format yyyy-mmdd or yyyy-mmdd-hhmmss
#and convert it to ticks
sub tconvert {
my $start = shift(@_);
$start =~ s/-//g;
my $year = substr($start, 0, 4);
my $month = substr($start, 4, 2);
my $day = substr($start, 6, 2);
my $hour = substr($start, 8, 2);
my $min = substr($start, 10, 2);
my $sec = substr($start, 12, 2);
$year = $year - 1900;
$month--;
my $now = timelocal($sec, $min, $hour, $day, $month, $year);
return $now;
}
1;
####
perl -I.. ./testintegers 2013-0923-173422 2013-0923-182819