in reply to Input validation

That depends on how you are expecting the line to look. Are there supposed to be a fixed number of fields, for example? In which case, you could check the size of the array returned by split, it will only have one entry if there were no '|' in $line. You could further check the individual entries, if you are expecting them to be strings, or numbers, in particular fields.

The 'not equals' regex, should be '!~', by the way, as '!$line =~' would do something different, I think. (Compare the negated $line, and not negate the result of the =~)

C.