Perl invoking print in a subroutine append 1 to the string?



Hi,

I created the following Perl subroutine to print string MALE or FEMALE. When subroutine is invoked, the print command suffixes a "1" at the end of the string. See the sample code and output below:

sub gender { 
    if ( (int rand(100)) >50) {
        print "MALE  ";
    }
    else {
        print "FEMALE";
    }
}   
 
foreach (1..5) {
    print &gender, "\n"; 
} 

OUTPUT:

FEMALE1
FEMALE1
MALE  1
MALE  1
FEMALE1
MALE  1

Why does this happen?



Use

print &gender();

and not

print &gender();