If I understand your updated question correctly, you are looking for an approach to the problem of associating the proper validation function to each column (or field) of a CSV record.

One approach would be to build an array  @col_validators in which each element of the array holds a reference to the validation function for the corresponding column of the data record; e.g., from the example you have given in your question, element 1 of the array holds a reference to the  is_int() integer data validation function.

This array would be built when the configuration file is parsed: as each config statement is parsed, the array is checked to see that a validation function has not been assigned to that column already, that the validation function exists, etc.; the function reference specified in the config statement is then assigned to the specified array element.

After the array is built, it should be checked to see that no empty slots exist or that any empty slots are filled with a reference to a null or error-reporting function.

When the array is used, it only remains the check that a column parsed from a record corresponds to an existing element in the validation array (if it does not, the record itself may be invalid), and you're done.

BTW -- Since your updated question is differs significantly from the original, a re-post seems warranted.


In reply to Re: Invoke sub whose name is value of scalar by Anonymous Monk
in thread Invoke sub whose name is value of scalar by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.