On Thu, Jul 3, 2008 at 9:47 PM, yitzle <[EMAIL PROTECTED]> wrote: > On Thu, Jul 3, 2008 at 11:03 AM, Roy M <[EMAIL PROTECTED]> wrote: >> Conside the following codes: >> >> use POSIX; >> >> print LONG_MAX, "\n"; >> >> my $num = 99999999994; >> print $num; >> >> >> Why $num is bigger than LONG_MAX ? > > It is a string maybe? >
OK. That wasn't clear. Perl doesn't have an int and string and char datatypes per say. Perl has a scalar and an array and a hash. Perl does this dynamic casting to int or string as needed. Consider the following code: perl -e 'use POSIX; print LONG_MAX . "\n"; my $x = LONG_MAX + 1; print "$x\n"; my $y = LONG_MAX * 2; print "$y\n";' I get the same number 3 times. But then I did this: perl -e 'use POSIX; my $x = 99999999999; print "$x\n"; $x = ($x - 1) / 2; print "$x\n";' It got no problems dealing with bigger numbers and does this correctly... Not what I would have expected to be honest... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/