Hi all, I've been toying with different techniques in how to make this code more compact. I have a few sanity checks like this, but against different incoming fields.
The problem I have, is that I don't like the fact that the "if" condition contains the exact same line of code that a sub-section of the add_message() function is receiving as a parameter. I know there is a way to bundle it better, but in my testing, I haven't been able to do it. While it may likely be mostly irrelevant, the code below is operating within the namespace of an object in the third level of the call stack. It has been passed a string to test (which gets copied into %$data), and an Error object which it must update if necessary. (I hope the code renders properly in the email). # item name if (length($data->{item_name}) == 0) { $error->add_message( "item_name is undefined" ); } if ($self->safe_string($data->{item_name})) { $error->add_message( "item_name has potentially dangerous chars:". $self->safe_string($data->{item_name}) ); } Steve ps. I'm currently working on a hash within my Vars class that will map names to error messages (and types).
smime.p7s
Description: S/MIME Cryptographic Signature