in reply to dynamically generated array variable
Your config file parser simply creates those variables instead of allowing to query them? To work with this bad design, you'll need to use symbolic references.
my $hostname = 'hosta'; my @host = do { no strict 'refs'; @$hostname };
Or if a reference is fine:
my $hostname = 'hosta'; my $host = do { no strict 'refs'; \@$hostname };
Update: I forgot to mention the above only works if @hosta is a package variable, not a my variable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dynamically generated array variable
by perlknight (Pilgrim) on Jan 02, 2007 at 21:03 UTC | |
by ikegami (Patriarch) on Jan 02, 2007 at 21:11 UTC | |
by shigetsu (Hermit) on Jan 02, 2007 at 21:14 UTC |