Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven!uvaarpa!mmdf From: marc@athena.mit.edu (Marc Horowitz) Newsgroups: comp.lang.perl Subject: Re: Need clarification of assoc. arrays Message-ID: <1991Jan31.033851.19246@uvaarpa.Virginia.EDU> Date: 31 Jan 91 03:38:51 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: marc@mit.edu Organization: The Internet Lines: 22 |> So, this should be written as |> |> for $i (keys %keyword) { |> print "the index is $i; the contents are $keyword{$i}\n"; |> } |> |> Use `print' instead of `printf' when you can; it is a tiny bit faster. Well, if speed is really a concern, you want to avoid interpolated strings. The fastest way to do that is for $i (keys %keyword) { print 'the index is ',$i,'; the contents are ',$keyword{$i},"\n"; } I'm using '' assuming that perl will try to interpolate in "" strings even if there is no interpolation to be done. If perl is smarter than that, great. (Is it, Larry?) Anyway, interpolation causes extra copies which you don't need, although I admit, the interpolation form is a lot nicer looking. Marc