in reply to Using currently selected filehandle

I'm not sure why you're doing this. print can already print to a filehandle:

print "Hello, world!\n"; select(STDERR); print "To STDERR\n"; select(STDOUT); print STDERR "Also on STDERR\n";

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Using currently selected filehandle
by sgifford (Prior) on Jun 23, 2003 at 18:20 UTC
    printto is a fairly complex 30-line sub which prints to a filehandle. To use print's default behavior, I would have to duplicate that entire sub, changing print $fh ... to just print .... I want to avoid doing that; it would require any changes to the output routines to happen identically in both places to avoid inconsistency, and my experience is that this is error-prone.

    Of course, if anybody has suggestions for another way to do this, I'm all ears!

      why not have your print method take an optional filehandle?

      ~Particle *accelerates*