Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Check for data in array

by thezip (Vicar)
on Feb 08, 2012 at 15:28 UTC ( #952520=note: print w/replies, xml ) Need Help??

in reply to Check for data in array

If I find that something that "something absolutely *should* work", yet doesn't, I create an override for the data by replacing the normal input with hardcoded values that test all possible conditions.

For example, just before entering into the "if" statement, hardcode %sections to contain:

$sections{'procs'} = 'service.exe'; # Should result in success #$sections{'procs'} = 'failure.exe'; # Should now result in failure

If the successful hardcode fails, then you have half-split the problem to determine that your logic is incorrect, rather than the data than is being supplied to it. If it works as expected, then your data is the problem.

Pretty basic stuff, but tricks like this allow you to remove all assumptions about the data you think you are processing.

What can be asserted without proof can be dismissed without proof. - Christopher Hitchens, 1949-2011

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952520]
[karlgoethebier]: @LanX ;-)
[LanX]: Wilkes left the computer field in 1972 to attend the Harvard Law School
[erix]: too many stubborn, illogical men in IT
LanX "We had the quaint notion at the time that software should be completely, absolutely free of bugs. Unfortunately it's a notion that never really quite caught on." :)
[LanX]: erix Silence, I sue you!
[erix]: She sounds like Dijkstra (you know, Edsger)

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2017-12-12 16:03 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (335 votes). Check out past polls.