in reply to Re^3: detecting an undefined variable
in thread detecting an undefined variable
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: detecting an undefined variable
by LloydRice (Beadle) on Sep 21, 2019 at 17:48 UTC | |
by AnomalousMonk (Archbishop) on Sep 21, 2019 at 20:25 UTC |