And how exactly is using the fieldnames from a database to dynamically create scalar variable names an improvement over using a hash to hold the fieldnames and their respective values? I'm really curious. With the hash method, you get one hash, easily transportable by hard reference, and easily manipulated. With the symbolic ref method, you get variable names that are created in the global symbol table hash, which you must continue to use via soft reference throughout the remainder of the script unless your script both dynamically creates the variable names and hard codes them. ...if it's the latter, and you're hard coding the names at later points in the script, may as well hard code them from the beginning instead of creating them on the fly.

The fact is that there are few good uses of symbolic references. An exception is the exporting of global variables between packages... but even this should be handled with care and often via the well-proven Exporter module. Many languages don't even allow the use of soft references, and yet they still get along just fine without them.


Dave


In reply to Re^3: Variable scalar creation. by davido
in thread Variable scalar creation. by snappybo

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.