[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] math and "big numbers"



Can someone please tell me what it is about Math on the Mac that I am missing?

I've written a date comparison script that runs just fine on Perl for Win32
(which I'm stuck with at work), or when I upload it to my Apache server.

When I try to run the script on MacPerl I get very strange numbers. The
library routines appear the same so I'm not sure what the problem is. I
found the script below in the O'Reilly's CGI book which is very similar to
the code I am using. It too will run on Win but not the Mac.

On the Mac this script tells me there are 34193 days until tommorow, or for
that matter ANY day in the future!

And I was jusy beginning to feel like I understood MacPerl  :-(

#!/usr/local/bin/perl

require "timelocal.pl";
require "bigint.pl";

($chosen_date = $ARGV[0]) =~ s/\s*//g;

if ($chosen_date =~ m|^(\d+)/(\d+)/(\d+)$|) {
    ($month, $day, $year) = ($1, $2, $3);

    $month -= 1;

    if ($year > 1900) {
        $year -= 1900;
    }

    $chosen_secs = &timelocal (undef, undef, undef, $day, $month, $year);

    $seconds_in_day = 60 * 60 * 24;
    $difference = &bsub ($chosen_secs, time);
    $no_days = &bdiv ($difference, $seconds_in_day);
    $no_days =~ s/^(\+|-)//;

    print $no_days;
    exit(0);

} else {
    print " [Error in date format] ";
    exit(1);
}


TIA,

David

___________________________________________________________
David Turley
dturley@illuminet.net
Fredericksburg, VA
USA

"If you want to know what God thinks about money, just
     look at the people He gives it to."
                                     -- Old Irish Saying

___________________________________________________________




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch