Um...I just wrote twisted routine to handle a bunch of symbolic references. This is a code snippet where I pass in the name of a variable, and use it to construct 3 different symbolic variable names that seem to all work (the variables are 'package' variables declared using 'our'. How is this different?
AH... just verified: Our vs. my.
sub _common_setvar { my $XX = shift; # XX=(db|cache) no strict 'refs'; my $XX_prefix = $XX . '_prefix'; debug("path_ops","_XX_prefix=%s",$XX_prefix); if (@_) { $$XX_prefix = $_[0]; my $_XX_prefix_set = "_" . $XX_prefix . "_set"; debug("path_ops","_XX_prefix_set=%s",$_XX_prefix_set); $$_XX_prefix_set = True; my $_save_XX_prefix = '_save' . $$XX_prefix; if ($_storage_dir_set) { my $tmp = $$_save_XX_prefix = _path_cat($storage_dir,$$XX_prefix); debugn("path_ops", "cmn_sv: sd=%s, ddXX_p=%s, ddsave_XX_p=%s, ", $storage_dir, $tmp, $$XX_prefix); _dir_check($$_save_XX_prefix); } } $$XX_prefix; } sub db_prefix { my $this=shift; _common_setvar('db',@_); debug("path_ops","db=%s, sdb=%s",$db_prefix,$_save_db_prefix); } sub cache_prefix { my $this=shift; _common_setvar('cache',@_); debug("path_ops","cache=%s, scache=%s",$cache_prefix,$_save_cache_ +prefix); }

In reply to Re^2: simple symbolic reference Q by perl-diddler
in thread simple symbolic reference Q by perl-diddler

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.