in reply to close statement issue
When working with pipes it is advisable to wait for the subprocess to terminate before closing the pipe (e.g. by allowing the program to exit by default in this case). Also, use "or" and "and" rather than || and && when everything to the left is a complete statement for which the or and and is to operate on the truth value, otherwise it is apt to operate on only part of the statement (an error). For example:
use POSIX ":sys_wait_h"; my $mpid = open my $mh, "| /usr/sbin/sendmail" or die "$!"; print $mh << "EOF"; To: joe@here.com From: smith@here.com Subject: data subject message body here EOF close $mh or die "$!"; waitpid $mpid, 0;
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: close statement issue
by ysth (Canon) on Mar 02, 2007 at 08:11 UTC | |
by Moron (Curate) on Mar 02, 2007 at 10:28 UTC | |
by ysth (Canon) on Mar 02, 2007 at 12:10 UTC | |
by Moron (Curate) on Mar 02, 2007 at 12:17 UTC |