use strict; use warnings; my $x = 10; my $y = undef; my $check = '$x,$y'; my @vars = split /,/,$check; for (@vars) { if (defined(eval($_))) { print "$_ = Defined\n"; } else { print "$_ = Not defined\n";} } __END__ $x = Defined $y = Not defined
There are risks associated with eval so you need to watch out
cheers
SK
In reply to Re: Access variable names
by sk
in thread Access variable names
by andreas1234567
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |