> I forgot to mention:
>
> I like the way you have the hash on the 2nd part of your reply,
> but creating
> that hash from the arrays I specified seems more complicated that
> the former
> solution.  Is there an easier way to do that?

You mean dynamically create the hashes?
You can do something like:

@nbservers = qw(bob1 bob2 james1 james2 james3);

$servers{'www.blob.com'} = [ @nbservers[0..1] ];
$servers{'www.james.com'} = [ @nbservers[2..5] ];

Note the [ ] - you need to do this to create an anonymous array reference
(otherwise you are assigning a list to the hash which will get converted to
a scalar - the size of the list).

But I thought the two hashes are 'cleaner' in that they are easier to
manage. To add extra servers you only have to change %servers (with your
arrays you also need to change @number_of_servers) and you don't have to
worry about keeping @nbnames and @logpaths 'lined up' - where the first
entry of @nbnames must correspond to first entry of @logpaths, etc.

And besides, if you just look at the declaration of the hashes, you can tell
straight away which server is associated with which hostname. (Try doing
this with about 50+ servers, and then imagine coming back after six months
to add/modify some of the servers).

> %servers = (
>       'www.blob.com'  => [ 'bob1', 'bob2' ],
>       'www.james.com' => [ 'james1', 'james2', 'james3' ]
> );
>
> %serverinfo = (
>       bob1    => 'blogs1',
>       bob2    => 'blogs2',
>       james1  => 'jlogs1',
>       james2  => 'jlogs2',
>       james3  => 'jlogs3'
> );

Zoltan.


---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to