Re: [exim] two failing approaches to solving my problem - lo…

Top Page
Delete this message
Reply to this message
Author: Heiko Schlittermann
Date:  
To: exim-users
Subject: Re: [exim] two failing approaches to solving my problem - lookingfor help
Hello Josh,

exim-users.josh@??? <exim-users.josh@???> (Mi 24 Jun 2009 10:03:29 CEST):
>
> First, my general question, since it will haunt me well beyond my
> immediate problem - is there a way to have persistent (e.g. global or
> package-scoped) variables (including hashes, arrays, and
> objects/things like database connections) across multiple calls to
> perl, other than the pre-defined scalars offered by Exim?


AFAIK: no.

> In this case, I'm loading up multiple lines in a text file into a
> global hash in perl, hoping to do it once and read from the hash
> subsequently, but I find the hash is undefined at the start of each
> call, and the code has to read the file again. Therefore, I figure
> each new call is in a different and fresh lexical scope and so my hash
> is gone. The code is ostensibly working, mind you, but it's doing a
> lot of needless reading/IO on the text file (once for each incoming
> message), and soon the system will be under heavy load.


Exim fork()s a new instance for processing each incoming connection,
thus you'll have a fresh perl each time, because loading perl is delayed
until it's needed.

But -- moment - you're looking for "static" data, for a preloaded
hash/array/whatever, to do your lookup.

May be you can test setting ``perl_at_start'', it will read your perl
file before any fork()ing and you may be able to use some BEGIN{} block
or to do other global things.

    # "doing initialization\n";
    my @a = ...


    sub mySub {
        ...
    }


> Another (preferred, in this case) approach to my immediate problem
> would be to use a return value from a perl sub as something for Exim
> to lookup in my text file, which has many single word values separated
> by newlines. In my ACL, I tried
>
> condition = ${lookup{perl{mySub}{$local_part}}{/etc/exim4/myTextFile.txt}}


This works for me:

exim4 -C test -v -be '${lookup{${perl{mySub}{a}}}lsearch{/etc/exim4/tt}}'

    Best regards from Dresden/Germany
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann HS12-RIPE -----------------------------------------
 gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
 gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B -