Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3843332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:55:21+00:00 2026-05-19T15:55:21+00:00

I want to write a app that can be extended via plugins, using Perl

  • 0

I want to write a app that can be extended via plugins, using Perl and Moose. I know there are a few Moose modules for writing plugins and I know there are other ways.

What are my options? and what should I know about them? any thing I should think about before implementing a plugin system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:55:22+00:00Added an answer on May 19, 2026 at 3:55 pm

    There are a few ways to provide extensibility; allow the user to apply roles to your class, or allow them to pass in small objects that do the interesting things (delegates). Delegates perform better than roles, but will require that you plan for all the extensibility up front. Roles allow more ad-hoc behaviors.

    Here are two CPAN distributions that take each approach:

    Delegates: AnyEvent::Subprocess

    Roles: Devel::REPL

    Plugin roles are implemented with MooseX::Object::Pluggable.

    Delegates are implemented however you like; the pattern is passing an instance of a class A that does some role R to class C, and then class C delegates to A. Here’s an example:

    package Compare;
    use Moose::Role;
    requires 'compare';
    
    
    package SpaceshipCompare;
    use Moose;
    with 'Compare';  
    
    sub compare { my ($a, $b) = @_; return $a <=> $b }
    
    package Sort;
    use Moose;
    
    has 'comparer' => (
        is       => 'ro',
        does     => 'Compare',
        handles  => 'Compare',
        required => 1,
    );
    
    sub my_sort {
        my ($self, @list) = @_;
        return sort { $self->compare($a, $b) } @list;
    }
    

    Then you use this like:

    my $sorter = Sort->new( comparer => SpaceshipCompare->new );
    my @sorted = $sorter->my_sort("1one", "0", "43");
    

    If you want the way Sort works to change, you just create a new class that does the Compare role, and then pass an instance to Sort’s constructor. Instant flexibility!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an app that takes in a model filename via cmd
i want to write a simple web app that can connect to databases and
We want to write a Windows/OS X app that sends podcast ratings info from
I want to write a little app for myself which notifies me if there
I want to write a little DBQuery function in perl so I can have
I want to write an app that will allow a program like iTunes which
I want to write an App that monitors my paired bluetooth connection in the
I want to write an app that stores its data in a file that
I want to write a screenshot app that grabs a screen shot, saves it
I want to write a windows service that will communicate with my win app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.