On Tuesday, June 3, 2003, at 11:24 PM, Richard E.Adams wrote:


I am working through the exercises in Chapter 1 of Learning Perl, Second Edition, O'Reilly publishers. I am using MacOS X (10.1.5), and Perl, v.5.6.0. An excerpt from one of the author's programs shows the following three lines:

open MAIL, "|mail YOUR_ADDRESS_HERE";
print MAIL "bad news: $someone guessed $someguess\n";
close MAIL;

($someone and $someguess have been assigned appropriate values prior to the above three lines.)

I suspect the above works fine in a typical UNIX environment, e.g.,

open MAIL, "|mail [EMAIL PROTECTED]";
print MAIL "bad news: $someone guessed $someguess\n";
close MAIL;

How can I get the above to work on my Macintosh? (I don't get an error message, nor do I receive an email.) Any help would be greatly appreciated.

Try standard debugging techniques (also, sendmail should be active). For example, if you'd try on the command line

mail YOUR_ADDRESS_HERE

You'd see right away it then prompts you for a subject!
Then you could start entering text - in effect you'd need two lines
of text, theoretically.  This could be obviated by using the -s option
and programming accordingly.  It also doesn't hurt to ALWAYS
program defensively, for example:

open (MAIL, "|mail YOUR_ADDRESS_HERE") || die ("Could not open mail\n");

(Note the use of parenthesis for both phrases. Also, I use a subroutine instead of "die",
but this is ok for a quick example.)


Hope this helps!

Bohdan

PS - using the command "mailq" will give you an idea of what's in your mail queue.


Richard E. Adams Email: [EMAIL PROTECTED]




Reply via email to