daniel kaplan wrote:
i want to turn this line
open MAIL, "| /usr/sbin/sendmail -t" || die "Could not open sendmail: $!";
into something that goes like
some variable = open MAIL, "| /usr/sbin/sendmail -t";
if (!some variable)
how do i? am too new at perl
What have you tried? As documented, open() returns undef on failure and
a non-zero value on success, so it should work just about how you've
written it:
my $some_variable = open MAIL, '| /usr/sbin/sendmail -t';
if (!$some_variable) {
...
}
That's if you *really* want to store the result of the open() for later.
If all you want is to execute a block of code when it fails, instead of
just a die(), you could do this:
unless (open MAIL, '| /usr/sbin/sendmail -t') {
...
}
By the way, you shouldn't be piping directly to sendmail - there are
CPAN modules that are simpler, and don't rely on the presence of a
specific mailer.
sherm--
--
Cocoa programming in Perl:
http://camelbones.sourceforge.net
Hire me! My resume:
http://www.dot-app.org