[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TMTOWTDI



>>>>> "VB" == Vicki Brown <vlb@cfcl.com> writes:

VB> #    1) write the returned data to a file, open it, and loop through the lines

	. If the data is needed as an audit trail or historical reasons.
	. The data may be needed for a later step

This is really a seperate question since The loop through the lines
actually is then either #2 or #3.

	@q = <FILE>
	{local($/); $q =<FILE>}; # with a split
	while(<FILE>) { ... };

VB> #    2) do an open with a pipe when you call the external command and attach
VB> #       the data to the filehandle, then iterate over <HANDLE>

#2 is good
	. Single pass does it all
	. You have other things to do while the data is being generated.
	. You don't want to allocate multi megabytes to holding the data
	  in memory
	. the processing algorithm fits the one at a time style.

VB> #    3) stuff the returned data into a large string variable, split it, and
VB> #       foreach across the result

VB>           $result = `command`;

Err, that should @result = `command`, waste of time or space unless you
really want everything in one string.

#3 is good
	. You need/want to do multiple passes
	. You have nothing else to do while the data is being generated
	. Not very much data at a time
	. You need all of the data at the same time

VB> #    4) none of the above (in which case what would you do?)

Hmm, I can't think of anything else.

<chaim>
-- 
Chaim Frenkel					     Nonlinear Knowledge, Inc.
chaimf@pobox.com				               +1-718-236-0183

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org