The short answer: Don't worry about it. Use whatever is more readable and whatever makes sense in your application. If you're talking about 30 arbitrary variables built using soft references, for example, I would vote 100% for going with a hash.
The long answer: Any scalar variable is stored in an SV internally. A hash is just a container around a bunch of SV's. I don't know if either method will be necessarily "less efficient" (are you talking about memory or execution time?). On one hand you have the hash lookup to find the value you're looking for in a hash, and on the other hand you have a symbol table lookup for individual scalars (though I guess different variable scoping conventions could make that work differently -- someone else may be able to provide more information).
I honestly don't think there's any serious gain one way or the other, and as a Perl developer you shouldn't have to worry about such a thing, especially with only 30 variables. Use what makes the most sense in your code, but avoid playing tricks with soft references that could come around and bite you in the ass later on. Hope this helps.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.