Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: plugins and inheritance

by baku (Scribe)
on Feb 28, 2001 at 01:32 UTC ( #61181=note: print w/ replies, xml ) Need Help??


in reply to plugins and inheritance

My suggestion would be similar to the 'registry' idea, but rather than listing out the various plug-ins in a central file, which will have to be maintained in some way (RegClean is your friend), you could grab the first x bytes of each file and search for the @ISA and package declarations.

(You might also want to check the eol characters (\012 vs \015 vs \012\015), depending upon how much you trust your 'potentially naïve end users,' to borrow a Micros0ftian phrase.)

Depending upon local system configuration, &c., a 'chunk' size of 512 bytes or 4KB might be best. (iirc, 512 byte blocks are +/- standard on most Unices, MacOS, and ?Win/DOS?. 4KB is the size of Linux's read-ahead, and quite likely other OSen, so if you read 1 byte from a file, it's likely that 4KB are cached by the OS, you'd just as well use them.)

Regardless, parsing the package and @ISA elements in the first "chunk" of the file gives you a simple way to identify the parent class to be replaced, and the name of the class to import (assuming that the filename itself is likely to be truncated, modified, or generally abused.)


Comment on Re: plugins and inheritance
Select or Download Code
Re: Re: plugins and inheritance
by idsfa (Vicar) on Aug 29, 2003 at 15:18 UTC
    Rather than manually parsing the files consider this snippet. Since perl already maintains a registry of installed modules (ExtUtils::Installed), why write your own?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://61181]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2014-07-26 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (177 votes), past polls