I have some Perl code that's doing something bizarre that I can't figure out. I have two variables defined ahead of this section of code:
$latestPatch = '000';
$test_setup{appl}{Rev0_OK} = 'F'; # a hash element
Both are defined as strings. If I print out the raw variables (wrapping ' around them), 'int($latestPatch)'
is '0'
and '$test_setup{appl}{Rev0_OK}'
is 'F'
. So far, as expected. Now I run the following:
$shouldInstall = int($latestPatch) == 0 &&
$test_setup{appl}{Rev0_OK} eq 'T';
$shouldInstall
ends up with a null value (false/0 expected)! (printing '$shouldInstall'
gives ''). Step-by-step debug statements (not shown) indicate that int($latestPatch) == 0
works OK, giving a 1 (TRUE), but $test_setup{appl}{Rev0_OK} eq 'T'
is null '' (and thus $shouldInstall
is ''). If I change the test to $test_setup{appl}{Rev0_OK} eq 'F'
, it is 1 (TRUE). If I change the test to $test_setup{appl}{Rev0_OK} ne 'F'
, it is again null. What's going on here? There are no error messages being issued. I do have boolean variables TRUE and FALSE defined (as int 1 and 0).
aTdHvAaNnKcSe