in reply to why can't compare a variable with undef directly?
I want to know the reason why I have to use defined when I need to know whether a variable is defined instead of using direct comparison with undef. For example this code isn't work as I expected ...output: $number is defined
Why do you expect the wrong thing? Where do you get your perl information from? Where did you learn that "" is the same as undef?
"" is never undef, its ""
|
|---|