Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
go ahead... be a heretic
 
PerlMonks  

Re^4: Breaking The Rules

by dsheroh (Monsignor)
on Jun 01, 2006 at 11:41 UTC ( [id://553072]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 14: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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://553072]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.