Passing a filehandle as parameter

To keep things maintainable we split our program in modules, classes, functions… In perlsub from the execellent perl documentation you can lookup the syntax of how to use functions. Offcourse, you have to digg pretty deep to find out how you can pass a filehandle:

# clientproc(*STDOUT);
# pass the socket
clientproc(*CH);

sub clientproc
{
  $fh = shift;
  print $fh "hello world";
}

This entry was posted on Thursday, October 20th, 2005 at 02:23 and is filed under Perl. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.