> That doesn't seem so undisciplined to me.

It's fragile and opens the door to many hard to debug potential problems.

Though most people were interpreting your intention as trying to use $$symbolic dereference. That's why I asked for more context.

Using hashes for optional values is a common pattern.

> I often put together pieces of code from various places.

Well, the common pattern for that class of problems is to use modules with stable APIs.

If you really want to do code generation by composing code chunks, then consider using package declarations and inspecting an our $scale variable in the STASH

use strict; use warnings; package Chunk; #our $scale =42; package main; my $myscale = $Chunk::{scale} // 1; print $myscale;

but now that you use packages you're only one step away of using modules ...

HTH! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice


In reply to Re^4: detecting an undefined variable by LanX
in thread detecting an undefined variable by LloydRice

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.