"robust" and "variable of a variable" (which has the connotation of wielding symbolic references) are not generally two concepts that co-exist peacefully. While it may be possible to create something robust that uses symbolic references, it's a practice that 40 years of computer science have moved us away from vigorously, and for good reason. There are a few situations where symbolic refs may be exactly the right tool (and Perl does allow them), but more often than not they represent a design flaw.

Your script seems to want to carry the notion of $section as a string at one point, and $section as a variable later. Converting a string to a variable is a symbolic reference. There are better tools for that. Using a hash allows you to make the variable always be a variable, and make its keys always be strings. That's safer, and reduces the possibility of things going really wrong. It improves robustness.


Dave


In reply to Re: Is it possible to call prepare statement with a variable of a variable? by davido
in thread Is it possible to call prepare statement with a variable of a variable? by dirtdog

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.