Hello Experts,
I tried googling to get more information about comparison operators in Perl when incompatible data types were involved but wasn't lucky.
I am basically a Java programmer but have been looking at Perl code of late, at work. While debugging a Perl module, I stumbled upon the following code block. I understand Perl has distinct comparison operators for numeric and string data types. But, I am not sure how this works.
When I run this code block, surprisingly the output of the above code block is 'n equals 0'.
I am not sure how a character ('n') be equal to a numeric number (0). Even the ASCII character value of character ('n') is not 0. Can some Perl guru help me understand what is going on?
Thanks,
I tried googling to get more information about comparison operators in Perl when incompatible data types were involved but wasn't lucky.
I am basically a Java programmer but have been looking at Perl code of late, at work. While debugging a Perl module, I stumbled upon the following code block. I understand Perl has distinct comparison operators for numeric and string data types. But, I am not sure how this works.
Code:
use constant UNSUBSCRIBE => 0;
my ($value) = 'n';
if ($value == UNSUBSCRIBE) {
print 'n equals 0';
}
I am not sure how a character ('n') be equal to a numeric number (0). Even the ASCII character value of character ('n') is not 0. Can some Perl guru help me understand what is going on?
Thanks,
Comment