Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-10 Thread James G Smith

Doug MacEachern <[EMAIL PROTECTED]> wrote:
>On Tue, 3 Jul 2001, James G Smith wrote:
> 
>> The current code I have uses %INC, but I wanted to write
>> something like the following:
>> 
>> sub use : immediate {
>>   # do stuff here if logging
>>   return CORE::use(@_);
>> }
>
>you could just override CORE::GLOBAL::require.  you don't need to
>override the import, and your version of require will be called at the
>same time as the 'use'. 

Thanks!  I will see what I can do with that.
-- 
James Smith <[EMAIL PROTECTED]>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix



Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-09 Thread Doug MacEachern

On Tue, 3 Jul 2001, James G Smith wrote:
 
> The current code I have uses %INC, but I wanted to write
> something like the following:
> 
> sub use : immediate {
>   # do stuff here if logging
>   return CORE::use(@_);
> }

you could just override CORE::GLOBAL::require.  you don't need to
override the import, and your version of require will be called at the
same time as the 'use'. 




Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread Robin Berjon

On Tuesday 03 July 2001 16:46, darren chamberlain wrote:
> James G Smith <[EMAIL PROTECTED]> said something to this effect:
> > The current code I have uses %INC, but I wanted to write
> > something like the following:
> >
> > sub use : immediate {
> >   # do stuff here if logging
> >   return CORE::use(@_);
> > }
>
> To go OT here, what would 'immediate' be doing here, if Perl
> supported it?

It would run, well, immediately :) C is run before the rest of the code 
(apart from BEGIN blocks) which is why one can't overload it (now) iirc.

-- 
___
Robin Berjon <[EMAIL PROTECTED]> -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
---
In which level of metalanguage are you now speaking?




Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread darren chamberlain

James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/03/2001:
> darren chamberlain <[EMAIL PROTECTED]> wrote:
> > James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/02/2001:
> > > Apache::Use
> >
> > You can get this information from %INC, can't you? e.g.:
> 
> Most definitely.  However, you lose information about which 
> modules are needed more often than others.  There's no difference 
> between all scripts needing CGI.pm and one script needing 
> Foo::Bar.  

Good point.

> We also lose timing information.  If 90% of the modules are 
> loaded into the process with the last request before the child is 
> destroyed, there's no point in loading them during the 
> configuration phase.  We can help this a little by taking 
> snapshots of %INC at regular intervals (at the end of each 
> request, for example).
> 
> The current code I have uses %INC, but I wanted to write
> something like the following:
> 
> sub use : immediate {
>   # do stuff here if logging
>   return CORE::use(@_);
> }

To go OT here, what would 'immediate' be doing here, if Perl
supported it?

(darren)

-- 
The three most dangerous things are a programmer with a soldering
iron, a manager who codes, and a user who gets ideas.



Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread James G Smith

darren chamberlain <[EMAIL PROTECTED]> wrote:
>James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/02/2001:
>> How would something like this do:
>> 
>> NAME
>> 
>> Apache::Use
>> 
>> SYNOPSIS
>> 
>> use Apache::Use (Logger => DB, File => "/www/apache/logs/modules");
>> 
>> DESCRIPTION
>> 
>> Apache::Use will record the modules used over the course of the 
>> Perl interpreter's lifetime.  If the logging module is able, the 
>> old logs are read and frequently used modules are automatically 
>> loaded.  Note that no symbols are imported into packages.
>
>You can get this information from %INC, can't you? e.g.:

Most definitely.  However, you lose information about which 
modules are needed more often than others.  There's no difference 
between all scripts needing CGI.pm and one script needing 
Foo::Bar.  

We also lose timing information.  If 90% of the modules are 
loaded into the process with the last request before the child is 
destroyed, there's no point in loading them during the 
configuration phase.  We can help this a little by taking 
snapshots of %INC at regular intervals (at the end of each 
request, for example).

The current code I have uses %INC, but I wanted to write
something like the following:

sub use : immediate {
  # do stuff here if logging
  return CORE::use(@_);
}
-- 
James Smith <[EMAIL PROTECTED]>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix



Re: RFC: Logging used Perl Modules (was Re: API Design Question)

2001-07-03 Thread darren chamberlain

James G Smith <[EMAIL PROTECTED]> said something to this effect on 07/02/2001:
> How would something like this do:
> 
> NAME
> 
> Apache::Use
> 
> SYNOPSIS
> 
> use Apache::Use (Logger => DB, File => "/www/apache/logs/modules");
> 
> DESCRIPTION
> 
> Apache::Use will record the modules used over the course of the 
> Perl interpreter's lifetime.  If the logging module is able, the 
> old logs are read and frequently used modules are automatically 
> loaded.  Note that no symbols are imported into packages.

You can get this information from %INC, can't you? e.g.:

use Time::Local;
use Data::Dumper;
use Apache;

warn map sprintf("%-20.20s\t%s\n", $_, $INC{$_}), keys %INC;

Exporter.pm /usr/local/perl/5.6.0/Exporter.pm
Carp.pm /usr/local/perl/5.6.0/Carp.pm
XSLoader.pm /usr/local/perl/5.6.0/i686-linux/XSLoader.pm
mod_perl.pm /usr/local/perl/site_perl/5.6.0/i686-linux/mod_perl.pm
strict.pm   /usr/local/perl/5.6.0/strict.pm
Apache/Connection.pm/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Connection.pm
Time/Local.pm   /usr/local/perl/5.6.0/Time/Local.pm
Apache/Table.pm /usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Table.pm
DynaLoader.pm   /usr/local/perl/5.6.0/i686-linux/DynaLoader.pm
overload.pm /usr/local/perl/5.6.0/overload.pm
Apache/Constants/Exp
/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Constants/Exports.pm
AutoLoader.pm   /usr/local/perl/5.6.0/AutoLoader.pm
Apache/Server.pm/usr/local/perl/site_perl/5.6.0/i686-linux/Apache/Server.pm
Data/Dumper.pm  /usr/local/perl/5.6.0/i686-linux/Data/Dumper.pm
Apache.pm   /usr/local/perl/site_perl/5.6.0/i686-linux/Apache.pm

Isn't this more or less what you mean?

(darren)

-- 
My studies in Speculative Philosophy, metaphysics, and science are all
summed up in the image of a mouse called man running in and out of every
hole in the Cosmos hunting for the Absolute Cheese.
-- Edmund Burke