
spf at anarres
Oct 19, 2004, 8:51 AM
Post #4 of 4
(2574 views)
Permalink
|
|
Re: [srs-discuss] Implementing Mail::SRS in MIMEDefang
[In reply to]
|
|
On Sun, 3 Oct 2004, Michael Faurot wrote: > > In article <200410031748.I93HMMDZ089517 [at] asarian-host> you wrote: > > > The "die" statements are quite the standard way of doing things in Perl > > modules. So this is actually really a Perl question. > > I thought my difficulty might involve something like this as I haven't > had much reason to use modules, until now. > > > At any rate, you should enclose SRS calls in an 'eval' function, which will > > return undef upon die. Like so: > [...] > > my $address; > > if (eval {$address = $srs -> reverse ($to)}) { > > This does indeed solve my difficulties. Thanks! > > Perhaps example code using eval could be incorporated into the POD > documentation? Presumably someone that does enough of this stuff, probably > already knows that they should use eval, but for folks like me that are > looking at the docs for example code just to get something working, > would appreciate it. :) Strictly speaking, you should inspect $@ and not rely on the returned value. my $address = eval { $srs->reverse($to); }; unless ($@) { ... } However, if the code ever returns undef (which I don't think it can), that would also be an error, so your code is fine. I will some examples in the documentation forthwith. Perhaps the code in Daemon.pm offers the best examples. S. -- Shevek http://www.anarres.org/ Robust Sender Policy Framework (SPF) http://www.libspf2.org/ SRS for the next generation http://www.libsrs2.org/ ------- To unsubscribe, change your address, or temporarily deactivate your subscription, please go to http://v2.listbox.com/member/?listname=srs-discuss [at] v2
|