develooper Front page | perl.beginners | Postings from April 2002

RE: associative array not looking like I thought it would

Thread Previous | Thread Next
Timothy Johnson
April 25, 2002 15:03
RE: associative array not looking like I thought it would
Message ID:

That's not the way associative arrays work.  They are stored differently.
If you want them to be printed in a certain order, then you must do it
explicitly.  I think it is really better to think of it as a hash instead of
an associative array for that reason.  Not all of the rules apply.  I
commonly use a snippet of code like this when I'm printing hashes:

foreach(sort keys %hash){
   print $hash{$_};

-----Original Message-----
From: P. S. Starkey [mailto:pstarkey@cinergy.com_strip_this_off]
Sent: Thursday, April 25, 2002 2:06 PM
Subject: associative array not looking like I thought it would

I have some perl script (shown below) and I am wondering why the associative
array being built ends up looking like the printout of the array as shown
after the code.  I would have assumed the array entries would have been
shown in the same order they are put into the array but that is not

%Error=( Error=>"[$ciTDF{'#errval_V'}]: $ciTDF{'#errtext_V'}",
   "Document Name"=>$ciTDF{'DOC_NAME_V'},
   Desc=>"Issuing-could not index to vault",
   Notes=>"Clean Vault Log");

  DB<3> p %Error
Document NamePARRYTESTERR12NotesClean Vault LogError[142]: BCI Err : More
than one match for a record in the BEF input fileDescIssuing-could not index
to vaultRevision1

To unsubscribe, e-mail:
For additional commands, e-mail:

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About