in reply to symbol table vs. eval
This will do what you want, I think:
my $test="my_variable_name"; my $default_value="the value I set"; $$test = "old value"; print "the value of \$my_variable_name = $my_variable_name\n"; $my_variable_name = "A new value"; print "the value of \$my_variable_name = $my_variable_name\n";
... but don't do that :)
Update: Perhaps I read & posted too quickly, does this do what you want?
my $test="my_variable_name"; my $default_value="the value I set"; $default_value = *$test; $$default_value = "old value"; print "the value of \$my_variable_name = $my_variable_name\n"; $my_variable_name = "A new value"; print "the value of \$my_variable_name = $my_variable_name\n";
Update2: Thanks ikegami. You'll notice I omitted the obligatory "use strict;" and "use warnings;", because when they're not omitted:
$ perl symbol.pl Global symbol "$my_variable_name" requires explicit package name at sy +mbol.pl line 12. Global symbol "$my_variable_name" requires explicit package name at sy +mbol.pl line 13. Global symbol "$my_variable_name" requires explicit package name at sy +mbol.pl line 14. Execution of symbol.pl aborted due to compilation errors.
$/ = q#(\w)# ; sub sig { print scalar reverse join ' ', @_ } + sig map { s$\$/\$/$\$2\$1$g && $_ } split( ' ', ",erckha rlPe erthnoa stJu +" );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: symbol table vs. eval
by raflach (Pilgrim) on Feb 23, 2006 at 18:49 UTC | |
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 | |
by chargrill (Parson) on Feb 23, 2006 at 19:03 UTC | |
|
Re^2: symbol table vs. eval
by ikegami (Patriarch) on Feb 23, 2006 at 18:45 UTC | |
by raflach (Pilgrim) on Feb 23, 2006 at 18:51 UTC | |
|
Re^2: symbol table vs. eval
by ikegami (Patriarch) on Feb 23, 2006 at 18:53 UTC |