Fish, David wrote:

>> Hello!  The problem I am having is I am pulling data from a table
>> in a certain order and loading it into the hash array but when I
>> read the hash array it comes out in a different order than it is
>> written.  What I have done as a work around, is the read the data
>> from a file that has it in the correct order.  Is there away to
>> build the hash so that it reads in the order it was created?

perldoc -q "hash remember the order"
How can I make my hash remember the order I put elements into it?
  Use the "Tie::IxHash" from CPAN.

          use Tie::IxHash;

          tie my %myhash, 'Tie::IxHash';

          for (my $i=0; $i<20; $i++) {
                  $myhash{$i} = 2*$i;
                  }

          my @keys = keys %myhash;
          # @keys = (0,1,2,3,...)

--
Henry Hartley
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to