Leila Lappin wrote:
> Hello all, > > I need to write a subroutine that validates several fields and returns one summary field containing names of what >failed. I was thinking of concatenating names of all fields that failed and return that string from the subroutine. Then >check the string (return value) and if it's not null update the data base with it. Is that considered a good style for >Perl? You're going to run into trouble just concatenating the field names- how would you be able to tell where one name started and another left off? You could separate them with some character and use split to get an array containing the names- but if you're going to do that, why not just push them onto an array and return that? in pseudocode: my @failed; if (field fails validation){ push @failed, $fieldname; } etc. Strings hide the structure of your data- to use data (other than a single string of course :) ) stored in a string you're going to have to go to the extra trouble of parsing the string. Better to use a data structure that supports the operations that you're going to need. But if all you're going to do with the return value is use it in a sql statement it would be reasonable to write a subroutine that returned a piece of that sql statement as a string (which would be a little (but maybe not much) more complicated than just concatenating the fieldnames), since that's all you will need. Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]