Re: adding a variable name to a hash to name is part of the variable name
- From: "Jürgen Exner" <jurgenex@xxxxxxxxxxx>
- Date: Sun, 22 Apr 2007 03:34:42 GMT
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
.
- References:
- adding a variable name to a hash to name is part of the variable name
- From: Bobby Chamness
- adding a variable name to a hash to name is part of the variable name
- Prev by Date: adding a variable name to a hash to name is part of the variable name
- Next by Date: newbie here: questrions about perl please
- Previous by thread: adding a variable name to a hash to name is part of the variable name
- Next by thread: newbie here: questrions about perl please
- Index(es):
Relevant Pages
|
|