in reply to Re^3: Breaking The Rules
in thread Breaking The Rules

You can't rely on warnings to tell you var didn't exist in the file, and you have no control over whether var gets defined.

Not true:

while (<FILE1>) { $var = GetVar($_) || $some_reasonable_default; };
$var is now guaranteed to have a defined value on every iteration, regardless of the file's contents. Granted, there are cases where there is no reasonable default, but, as the programmer, I do still have control over whether $var is defined or not, should I choose to exercise it.

Replies are listed 'Best First'.
Re^5: Breaking The Rules
by Unanimous Monk (Sexton) on Jun 02, 2006 at 18:01 UTC
    Regardless of when/how you make $var = $some_resonable_default, immediately prior to you giving it a default value, it was legitimately undefined for reasons beyone your control. i.e. Just prior to evaluating the RHS of ||, $var was undefined and you had no control over it.
      Just prior to evaluating the RHS of ||, $var was undefined and you had no control over it.

      I think the larger point that was being made was that it's a computer program; you always have control, because you can see all the situations where things might become undef. If your variables have short scope (as they should have) then it's easy to deal with the situations where undef should be changed to $some_default.

        I'm either missing your point, or your missing my point. Simply put, my point is: The fact that the input is bad can not be controled by your program. What you do with bad input can be.