http://qs1969.pair.com?node_id=592644


in reply to Re: dynamically generated array variable
in thread dynamically generated array variable

I did this and it works:
#use strict; $host = qw(@hosta); foreach $cnf (eval($host) { }
. is there a way to specify it so that I can use strict? Thanks.

Replies are listed 'Best First'.
Re^3: dynamically generated array variable
by ikegami (Patriarch) on Jan 02, 2007 at 21:11 UTC

    Yes. I already provided that. use strict does not give an error with the code in my previous post.

    use strict; use warnings; # ... Load config file ... my $hostname = 'hosta'; my @host = do { no strict 'refs'; @$hostname }; foreach my $cnf (@host) { ... }

    By the way, why are you using qw(...) to initialize a scalar. Don't you want
    $host = q(...);
    or the equivalent but more readable
    $host = '...';

Re^3: dynamically generated array variable
by shigetsu (Hermit) on Jan 02, 2007 at 21:14 UTC