On Thu, 29 Jul 2004, Brian Volk wrote:

Is there a way to print to both the STDOUT and a physical file. other than ./script.pl >>outfile.txt ? Here is what I have now, which works great, but I would like to see the links (about 2,000) scroll.

It's a cop-out, but can't you just have two print statements?

    while (...) {
        print $OUTFILE "$whatever";
        print          "$whatever";
    }

There's probably a clever & slightly-faster-running way to get one print statement to fork the output, but it may not be worth it.

Still, if you really want to do this in one statment, it may help to look at what the `tee` Unix command does: it's a command for doing exactly what you're asking for, sending the input it receives on standard input to both the controlling terminal and a specified file. I've never looked at `tee`'s source code, but I've always assumed that it too was just using dual output statements.



--
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to