i think your benchmark is a little off, since it's comparing global scalars to a lexical hash. hopefully this one's more accurate (but i'm no expert.)

Update:

here, global vars win in speed, as you quoted. i did not test memory requirements. of course, i meant that lexicals win... what was i looking at when i typed that?

#!perl use Benchmark; my %l_hash; sub use_global_hash { ++$hash{ 'foo' . $_ } for 0 .. 1000 } sub use_global_vars { ++${ 'foo' . $_ } for 0 .. 1000 } sub use_lexical_hash { ++$l_hash{ 'foo' . $_ } for 0 .. 1000 } timethese -10, { use_global_hash => \&use_global_hash, use_global_vars => \&use_global_vars, use_lexical_hash => \&use_lexical_hash, }; __END__ > t-b-symref.pl Benchmark: running use_global_hash, use_global_vars, use_lexical_hash +for at least 10 CPU seconds... use_global_hash: 11 wallclock secs (10.58 usr + 0.00 sys = 10.58 CPU) + @ 744.83/s (n=7884) use_global_vars: 10 wallclock secs (10.54 usr + 0.02 sys = 10.56 CPU) + @ 561.35/s (n=5925) use_lexical_hash: 11 wallclock secs (10.65 usr + 0.00 sys = 10.65 CPU +) @ 794.74/s (n=8460)

~Particle *accelerates*


In reply to Re: Symbolic refs aka. dynamic variables again by particle
in thread Symbolic refs aka. dynamic variables again by Jenda

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.