squale has asked for the wisdom of the Perl Monks concerning the following question:
# @_ is a list of variable name # if @_ contains "i" and "j" and $i == 42 $j eq "freeBSD", # the function should print : # i : 42 # j : freeBSD sub display_init { my @variables = @_; my $value; foreach (@variables) { eval("\$value=\$$_"); if (! defined($value) ) { $value = "undefined"; } print "$_ : $value\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: issues with eval (get a variable's value)
by shmem (Chancellor) on Sep 12, 2007 at 13:20 UTC | |
|
Re: issues with eval (get a variable's value)
by ikegami (Patriarch) on Sep 12, 2007 at 13:21 UTC | |
|
Re: issues with eval (get a variable's value)
by j1n3l0 (Friar) on Sep 12, 2007 at 13:09 UTC | |
|
Re: issues with eval (get a variable's value)
by Corion (Patriarch) on Sep 12, 2007 at 13:22 UTC | |
by squale (Initiate) on Sep 12, 2007 at 14:38 UTC | |
|
Re: issues with eval (get a variable's value)
by Anno (Deacon) on Sep 12, 2007 at 14:47 UTC | |
|
Re: issues with eval (get a variable's value)
by clinton (Priest) on Sep 12, 2007 at 13:03 UTC | |
by ikegami (Patriarch) on Sep 12, 2007 at 13:11 UTC |