On Mon, Jun 11, 2001 at 10:44:15AM -0400, Charles Lu wrote:
> &function_one (\*FILE);
[snip]
> &function_one("temp.txt");
[snip]
> Why is the first method almost always the preferred one?
Neither is overwhelmingly preferred over the other, that I've seen. The
only benefit to passing a reference, as opposed to passing the name (which
is just a string), is you can easily differentiate between a string and a
filehandle. This would be useful if, say, your function could accept a
handle, or a filename to open.
> More importantly, is it better to pass filehandle into a subroutin than
> pass in the name of the output file as arugument and construct(define) the
> filehandle WITHIN the subroutine?
You give no clarification on what you mean by "better". It's easier on the
subroutine writer to get a handle; it's easier on the caller of the
subroutine to pass a filename. You really can't make a mass generalization
that "passing a file(handle|name) is better"; it depends on the situation.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--