in reply to Re: symbol table vs. eval
in thread symbol table vs. eval
A clear case of my overthinking the problem. Your first example does what I am needing. However I wonder if you can explain why the following occurs:
Code:Output:package apackage; my $test="my_variable_name"; my $default_value="the value I set"; $$test = $default_value; print "the value of \$my_variable_name = $my_variable_name\n"; package main; $my_variable_name = "A new value"; print "the value of \$my_variable_name = $my_variable_name\n"; print "the value of the package variable = $apackage::my_variable_name +\n";
the value of $my_variable_name = the value I set the value of $my_variable_name = A new value the value of the package variable = the value I set
which works and is what I need,
but...
Output:package apackage; my $test="my_variable_name"; my $default_value="the value I set"; our $$test = $default_value; print "the value of \$my_variable_name = $my_variable_name\n"; package main; $my_variable_name = "A new value"; print "the value of \$my_variable_name = $my_variable_name\n"; print "the value of the package variable = $apackage::my_variable_name +\n";
Can't declare scalar dereference in our at -e line 5, near "$test =" Execution of -e aborted due to compilation errors.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: symbol table vs. eval
by ikegami (Patriarch) on Feb 23, 2006 at 18:59 UTC | |
by raflach (Pilgrim) on Feb 23, 2006 at 19:23 UTC | |
by ikegami (Patriarch) on Feb 23, 2006 at 19:37 UTC | |
Re^3: symbol table vs. eval
by chargrill (Parson) on Feb 23, 2006 at 19:03 UTC |