Am Do, 2.12.2010, 02:24, schrieb Xiao Lan:
> On Thu, Dec 2, 2010 at 3:38 AM, Mithun Bhattacharya <inz...@yahoo.com>
> wrote:
>> Can you confirm the error you are encountering using your current method
>> ?
>>
>> I would like to understand what you are trying to achieve by having a
>> global file handle - do you want to have modular code or does the
>> content of the file somehow determine which handler to be used ?
>>
>
> Hi,
>
> Thanks for the replying.
> I was giving the example by openning a file.
> In acutal I was using this module:
>
> http://search.cpan.org/~sunnavy/IP-QQWry-0.0.16/lib/IP/QQWry.pm
>
> For each client request if I open the data file:
>
> my $qqwry = IP::QQWry->new('QQWry.Dat');
>
> That will be slow IMO.
>
> So I was thinking to pre-open the data file in each process of apache
> and use it directly in each handler.
>
> How about this case? Thanks.
>
> Regards.
>

Hi.

You could do the following (and avoid any possible conflicts when using
the file descriptor globally - one thing that comes into my mind would be
seek):

In the perl file that holds your handler declare a variable on module level:

my $qqwry = undef;

In the handler instantiate the object if $qqwry is undefined:

if (not $qqwry)
{
  $qqwry = IP::QQWry->new('QQWry.Dat');
}

This way the file should be opened only once in each apache process (which
should be good enough for performance reasons). The my $qqwry on module
level should be persistent in each process.

Hendrik


Reply via email to