Stas Bekman wrote:

> pascal barbedor wrote:
> 
>>>>
>>> [ .... ]
>>>
>>>> config.pm file
>>>> ---------------------------------------------
>>>> package AFPA::Evolif::Config ;
>>>>
>>>> use XML::LibXML () ;
>>>> use XML::LibXSLT () ;
>>>> use XML::XPath () ;
>>>> use XML::Simple () ;
>>>> use DBI () ;
>>>>
>>> [ ... ]
>>>
>>> Hi,
>>>    Could it be that XML::XPath does file tests on the
>>> file $xmlfile passed to it through
>>>      XML::XPath->new(filename => $xmlfile)
>>> which would cause '_' to use the stat on $xmlfile, rather
>>> than the original config file?
>>>
>>> best regards,
>>> randy kobes
>>>
>>>
>>>
>>
>>
>>
>> oh yes, this was the answer !  XML::XPATh->new stats the file.
>>
>> thanks for clearing it out !
>>
>> then maybe the last line of reread_conf  in mod_perl guide should be
>> modified to
>>
>>  $MODIFIED{$file} = -M $file;
>>
>>   in case the do ( ) loads something which can possibily stat file.
> 
> 
> ok, I'll add a note, saying that _ shouldn't be used if it's not known 
> whether no other files are stat'ed in between. Or even the other way 
> around, so the default will be -M $file


At the end I've just cached the value of -M, and saved an otherwise 
needed stat() syscall :)


   use vars qw(%MODIFIED);
   sub reread_conf{
     my $file = shift;
     return unless defined $file;
     return unless -e $file and -r _;
     my $mod = -M _;
     unless (exists $MODIFIED{$file} and $MODIFIED{$file} == $mod){
       my $result;
       unless ($result = do $file) {
         warn "couldn't parse $file: $@" if $@;
         warn "couldn't do $file: $!"    unless defined $result;
         warn "couldn't run $file"       unless         $result;
       }
       $MODIFIED{$file} =  $mod; # Update the MODIFICATION times
     }
   } # end of reread_conf

-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/

Reply via email to