Jamie Risk wrote: > I'm a casual PERL programmer at best The best Perl programmers are the most casual :)
> I have a working facsimile of the non-working code below. > When I run it, I get an error "print() on closed filehandle > $fh at ./test.pl line [n]". > > This is just my first step to being able to pass file handles to my > sub-routines. What have I missed? > > open my $fh, "test" || die $!; > print $fh "Hello!\n"; > close $fh; You've opened the file 'test' for reading. Substitute open my $fh, '> test' or die $! and you'll be able to print to it. > Secondly, how do I pass STDOUT has a file handle to a sub-routine? It depends what the subroutine is expecting. If it's one that will already accept $fh (which is actually a reference to a globvalue) from your code above, then you can write mysub (\*STDOUT) or, perhaps more obviously my $fh = \*STDOUT; mysub ($fh); HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]