I suggest you test your code before posting:
use strict;
sub same_sign {
my ($x,$y) = @_;
if ( undef($x) or undef($y)) {
return 0; # "undef" is never same-sign
}
if ( ( ($x >= 0) and ($y >= 0) )
or ( ($x < 0) and ($y < 0) ) )
{
return 1;
}
else
{
return 0;
}
}
$\ = "\n";
print same_sign(1,1);
print same_sign(0,0);
print same_sign(undef,undef);
print same_sign(-1,-1);
print same_sign(-2,-2);
print same_sign(2,-2);
__END__
1
1
1
1
1
1
Your subroutine seems to suggest that all values passed in always have the same value sign...
Update: Correction thanks to lodin