[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Any way to Tee in MacPerl?



wwilliam@cisco.com,Internet writes:
>I'm writing a program that's eventually going to end up on UNIX and I
>need
>to write to two files (STDOUT and a file) simultaneously.

>I know that on UNIX, I can do:

>open(FILE, "| tee file2");

>print FILE "some text\n";

>and get my desired result.  However, unless someone's written a Mac
>version
>of tee, I don't think that's gonna work on the Mac (which is where I'm
>doing my development).   

When reading both the MacPerl list, and the mailing list for Perl for
Win32, one subject that comes up frequently is the lack of certain
commonly used UNIX commands and tools.  In most cases, the solution is
to come up with a pure Perl answer, which will have the advantage of
working on all platforms.

Consider the following pseudocode only: I have not tested it even for
syntactical correctness.

sub print22 {
	my ($text) = @_;
	print FILE $text;
	print STDOUT $text;
}

I'm not good enough to be sure, but I think you could even do something
like passing in pointers to the two files you want to print to, to make
it even more flexible.

R David Francis
Hyper Active, inc.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch