in reply to problem or bug?

if ($month + 0 == 7) { ... # Or, better would be ... @month_names = ( '', 'January', ... ); $monthStamp = $month_names[$month];

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: problem or bug?
by blakem (Monsignor) on Oct 11, 2001 at 23:15 UTC
    I think the '+ 0' trick to force a numeric value is unnecessary here. It looks like '==' already does that for you. (of course your second suggestion is better than either of these, but still...)
    #!/usr/bin/perl -wT use strict; my @vals = ('07','7',07,7,8); # eq tests for my $month (@vals) { print $month, $month eq 7 ? ' eq' : ' !eq', " 7\n"; } print "\n"; # == tests for my $month (@vals) { print $month, $month == 7 ? ' ==' : ' !==', " 7\n"; } print "\n"; =OUTPUT 07 !eq 7 7 eq 7 7 eq 7 7 eq 7 8 !eq 7 07 == 7 7 == 7 7 == 7 7 == 7 8 !== 7

    -Blake

Re: Re: problem or bug?
by softworkz (Monk) on Oct 11, 2001 at 23:07 UTC
    Thanks guys!! learn something new everyday! :)