From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ukhas jean Sent: 08 July 2006 16:32 To: active perl Subject: Should we use a scalar or an array for reading the contents of afile??
> Hello All, > > I was asked this by a superior of mine and was unable to give any sound explanation to this question. Can > anyone help?? > > When the contents of a file are read into an array and a scalar variable, which should be used for faster > processing of the contents?? > > Which one would be faster?? Using an array or a scalar variable?? My first answer would be that unless there was a pressing need to have the file in memory, reading line (or record) at a time will be a more scalable solution, so I wouldn't even consider the difference. My second answer would be "why do you need to know?". They say that there is no such thing as a stupid question, but sufficient information usually helps to provide a sensible answer. If you actually need the contents of the file in memory (File::Slurp is very useful for this) store it in a form that is most appropriate for the way in which you want to process the data. If that is not fast enough for your requirements then any difference in performance between storing the file's contents as an array or scalar is unlikely to be significant. Don't forget the first rule of optimisation "Don't do it yet", with the second rule being "I told you, don't do it yet". HTH ================================= Atos Euronext Market Solutions Disclaimer ================================= The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of Atos Euronext Market Solutions. L'information contenue dans cet e-mail est confidentielle et uniquement destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail vous parvient par erreur, nous vous prions de bien vouloir prevenir l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre systeme. Le contenu de ce message electronique ne represente pas necessairement la position ou le point de vue d'Atos Euronext Market Solutions. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
