in reply to int not working?

sub SBS_B2C{ my ($bin_date) = @_; my $year = 1900 + ($bin_date/365); print $year; #output 2004.41643835616 print int($year); #output 20041 } SBS_B2C(38112);
I'm gonna go out on a limb here and suggest that (a) this isn't quite the real code (since I see no newlines being printed), and (b) the real code is printing the return value of this subroutine, which will be a 1 from the print operator succeeding, and that's where the extra "1" is coming from after "2004".

Let's see if my psychic powers are right on both cases. {grin}

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: int not working?
by ysth (Canon) on May 06, 2004 at 16:26 UTC
    Or the real print statements are in the other order, and there is a comma between them, ala:
    perl -we'$foo="xyz"; $bar="pdq"; print $foo, print "$bar\n"'
Re: •Re: int not working?
by Scarborough (Hermit) on May 06, 2004 at 15:55 UTC
    Your right not excectly the finished code but I am printing in the sub routine just as a test. There is also a new line after the first print in my code. I will amend acordingly.
Re: •Re: int not working?
by Scarborough (Hermit) on May 06, 2004 at 16:04 UTC
    Thanks Merlyn I'm not sure I understand why I'm printing the 1 from the previous print statement but changing the code to
    my $year = int(1900 + ($bin_date/365)); print $year."\n";
    Works fine. Thank you for your help.