But there is the school of thought termed the robustness principle, that goes Be conservative in what you send, be liberal in what you accept.
I definitely prefer 'Be conservative in what you send, be conservative in what you accept.' I hold the opinion that trying to be liberal with input (especially: trying to fix malformed input) is pretty much guaranteed to lead to a bug somewhere later on.
@OP: Both of the suggestions BrowserUK gave are good. But trying to apply the robustness principle (-> be liberal in what you accept) and automagically initialize a hash reference may sound like a good idea at first but can turn out to be a bad one.
In reply to Re^4: Can't use an undefined value as a HASH reference
by Monk::Thomas
in thread Can't use an undefined value as a HASH reference
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |