If you want to write a subroutine that write the output to a text file you 
can do this:

open FILE ">temp.txt" or die;
&function_one (\*FILE);


sub function_one{
    my $fh = shift;
    print $fh "blah blah blah\n";
}

OR you can do this:

&function_one("temp.txt");

sub function_one{
    my $file = shift;
    open FILE ">$file" or die;
    print FILE "blah blah blah\n";
}

Why is the first method almost always the preferred one?  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?

thanks

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to