![]() |
die question
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 |
Re: die question
daniel kaplan wrote:
> i want to turn this line > > ... See reply in comp.lang.perl.misc. This group is defunct. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl |
Re: die question
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 |
| All times are GMT. The time now is 01:36 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.