On Thursday 30 Oct 2003 8:17 am, [EMAIL PROTECTED] wrote:
> Hi,
>
>
>
> For those of you who helped me with my earlier scripts. Thanks.
>
>
[snip]
>
> It seems to me the hash started almost at the bottom of the list instead of
>
> With the hostname and work it way down. Is there any way to force the
>
> Order other than maybe specifying the array itself?.
>
Hi Phil,
it states in the perl docs that the sequence of the keys returned from a hash
cannot be guaranteed, and even if they always return in the same order in the
current version, that may change in a future version of perl.
If you *need* the keys returning in a specific order, you have to code this
yourself.
One method I use is to have an array (which is always in the order specified)
and use that instead of the keys <hashname> clause.
For your example I'd use
my
@keylist=('hostname','os','osver','osrel','srvtype','srvmodel','memory','cpu');
and then
replace
foreach $CMD (keys %{$commands{$items}}){
with
foreach $CMD (@keylist){
>
>
> Phillip Bruce
> ISC Consultant, System Architect
> Location: Dublin, CA
> * Cell: 408-476-8658
> * Office: 925-560-7853
> AIM: OkieUnix
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]