Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

How do I modularize a script to use plugins

by Mik0r (Novice)
on Dec 07, 2008 at 03:56 UTC ( [id://728643]=perlquestion: print w/replies, xml ) Need Help??

Mik0r has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have been working on an IRC bot that uses POE::Component::IRC. What I have come up with is 1 massive perl script... Is there a way I can separate each main sub function of my perl script into a separate file then when I run the mail perl script it will read the contents of the separate files to act as "1 big perl script" again.

Example: myircbot.pl - will call the basic functions and then ill need a way to load each file ending with .pl in a folder called plugins back into the main script without reading/writing permanent changes to the main perl script.
  • Comment on How do I modularize a script to use plugins

Replies are listed 'Best First'.
Re: How do I modularize a script to use plugins
by Corion (Patriarch) on Dec 07, 2008 at 09:16 UTC
Re: How do I modularize a script to use plugins
by rowdog (Curate) on Dec 07, 2008 at 14:26 UTC
Re: How do I modularize a script to use plugins
by Lawliet (Curate) on Dec 07, 2008 at 04:17 UTC

    Yeah, there are ways, but why do you want to? Anywhat, (way, who, and how are already taken), try to make them into modules and then use them. Google and Super Search may help.

    Update: Just looked at the title of the OP -- added some links.

    I'm so adjective, I verb nouns!

    chomp; # nom nom nom

Re: How do I modularize a script to use plugins
by fmerges (Chaplain) on Dec 07, 2008 at 18:57 UTC

    Hi,

    What I don't understand is why you want to load .pl files to have again one big chunk of code?

    Have you read POE in detail, or are you just using PoCo::IRC? POE accept also object states and package states, which are for splitting the code into logical chunks, not just chunks.

    I would really review the code and encapsulate as required in different modules. Then about you plugins, well as other said, take a look at PoCo::IRC itself, it has some pluggable system, maybe also POE::Component::Pluggable; Module::Pluggable once you split your code but still want to have a plugin system; and Bot::BasicBot::Pluggable which is not POE but still.

    Regards,

    fmerges at irc.freenode.net
Re: How do I modularize a script to use plugins
by Mik0r (Novice) on Dec 08, 2008 at 01:55 UTC
    Thank you all for your help, I believe "do" is exactly what I was looking for. It allows me to easily break down my sub functions into a logical plugin, then use a loop with do, to add the plugins from the plugin folder that I want to use back into my script.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://728643]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2025-11-12 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.