On 1 Dec 2004, Prabahar Mosas wrote:

 
    Please check the below coding because I actually expect one 
output but this code print unpredictable output. I expect the 
following output. 
 
Apache 
Windows 
Dos 
Linux 
Unix 
Solaris 
 
But Machine giving output is below 
*********************************** 
Linux 
Apache 
Windows 
Unix 
Solaris 
Dos 
 
%Items = 
(Apache=>apache,Windows=>windows,Dos=>dos,Linux=>linux,Unix=>unix,Solaris=>solaris);
 
       foreach  $keys (keys %Items) { 
            print "$keys\n"; 
       }; 
 
Why this conflict?.  Please clear my doubt. I actually expect 
this out. 
 
Apache 
Windows 
Dos 
Linux 
Unix 
Solaris  
 
To get this output what I need to do Mail me as early as possible 
 



Well that's the way hashes work. If you have a recent version of Perl, at
least the order will be the same.

However to do what you want, you could use the Tie::IxHash module


use Tie::IxHash;

.....

tie %Items, "Tie::IxHash";


See the Perl Cookbook, Ch 5.6
See perldoc Tie::IxHash  
(Tie::IxHash - ordered associative arrays for Perl)



Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to