in reply to difference between 'if (condition) { expression;}' and 'expression if (condition)'
Note, however, that if you had warnings on (use warnings;), you would have seen something like this when executing example 2:
Use of uninitialized value in concatenation (.) or string at ./test.pl + line 5.
This is because you refer to a value ($var) which, while it is within the current scope, has never been set to any value (it is still undef). I find that such warnings are often an indicator that my code is doing something I don't expect or haven't prepared for.
|
|---|