in reply to Access variable names
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Access variable names
by andreas1234567 (Vicar) on Sep 01, 2005 at 12:09 UTC |