Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: dynamically generated array variable

by perlknight (Pilgrim)
on Jan 02, 2007 at 21:03 UTC ( #592644=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://592644]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-03-28 04:39 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (66 votes). Check out past polls.