Re: adding a variable name to a hash to name is part of the variable name



Bobby Chamness wrote:
I have a perl script that I wrote the loops through a list of servers
in a file and I want to create a hash with the server name in it.

You mean a the server name as part of the variable name? Well, maybe you
think that's what you want, but it is A Very Bad Idea (TM). See the FAQ "How
can I use a variable as a variable name?" and gazillions of previuos
discussions in CLPM for details.

I
want each server to have its own hash.

Just use a hash of (references to) hashes.

$server_$myserver_name{$some_key}

Why not
$servers{$myserver_name}{$some_key}

jue


.



Relevant Pages