in reply to Re^2: getting the name of a variable to use as string
in thread getting the name of a variable to use as string
You're approaching the problem backwards. Instead of taking a variable and getting the name out, take the name and turn it into a variable, with a symbolic reference. Something like this should work, though I haven't tested it:
foreach my $i (qw(foo1 foo2 foo3 ... foon)) { $hash{$i} = $$i; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: getting the name of a variable to use as string
by tilly (Archbishop) on Sep 17, 2004 at 14:50 UTC | |
|
Re^4: getting the name of a variable to use as string
by pmneve (Novice) on Sep 20, 2004 at 18:57 UTC |