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

[MacPerl] switching output from STDOUT to mail



I'm trying to make a program that works in two modes: demo and !demo.

If it's !demo, I want to open a pipe to mail and print stuff to mail.
If it's demo, I want to open to std out and print there (HTML, actually).
This is a stupid form-mail program that I have grossly overcomplicated.
Sorry about that.


I've done:
print "<HTML><BODY>Some Stuff";

if(!$demo){
        open (MAIL,"| $mailprog.....);
        &Print_Mail;
}
if($demo){
        print "<PRE>;
        open (MAIL,"| &2");
                #or >>&1 or |>>&1 and everything else I can thing of
        &Print_Mail;
        close(MAIL);
        print </PRE>;
}

sub Print_Mail()
        print MAIL "lines of data\n";
}
What seems to happen is that the output for the regular print statements is
spooled, and when I open MAIL for output it comes out ahead of all my HTML.

How can I correctly switch the print MAIL output so it streams with the
output from the other print statements??

tia
John.

--John Springer
 _______________________________________________________________________
 |        Can you use a creative, Internet-savvy marketing guy?        |
 |      Check Me Out at <http://www.scruznet.com/~springer/HireMe>     |
 |                                                                     |
 | [This Space Paid For by the California Employment Development Dept] |
 |_____________________________________________________________________|