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

RE: associative array not looking like I thought it would

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

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
To: beginners@perl.org
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
happening.

%Error=( Error=>"[$ciTDF{'#errval_V'}]: $ciTDF{'#errtext_V'}",
   "Document Name"=>$ciTDF{'DOC_NAME_V'},
   Revision=>$ciTDF{'DOC_REV_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: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About