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 7613589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:11:30+00:00 2026-05-31T02:11:30+00:00

We are using OOP perl as a programming languge to design this framework, so

  • 0

We are using OOP perl as a programming languge to design this framework, so this algo-like code is in Perl.

We are developing an automation framework in OOP Perl for an end-point device. This end-point device provides a HTTP, Telnet and SSH interface to execute the certain set of commands. For simplicity, we can assume that all commands are supported by all the three connection interfaces, generating the same output for a given command.

A function is written in the respective Connection class to handle a specific command.
e.g.

sub getVersion {
    return $http->sendCommand('version');
    }

But the current implementation of calling such function is little but different. Suppose, we would like to call the getVersion function, then it will be called something like this.

$device->getVersion(); //This is called through device object rather than connection object.

since this function is not defined in the device class, AUTOLOAD is called. In the Device class, AUTOLOAD is implemented like this

sub AUTOLOAD {
  my $connection = $device->getConnection();
  return $connection->$methodName (..); // when called for getVersion, $methodName will become the "getVersion"
  }

Please let me know if this is a good practice to implement it or should I modify it to remove the AUTOLOAD by implementing a function for each command in the device class, something like:

sub getVersion {
    my $connection = $device->getConnection();
    return $connection->getVersion();
}

We have 150+ such commands available through all the three interfaces (HTTP, Telnet, SSH).

  • 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-31T02:11:31+00:00Added an answer on May 31, 2026 at 2:11 am

    Class::Delegator is a good fit for a cleaner implementation. You could probably design a class that is the root behavior, say Connected, which defines how to get a connection.

    {   package Connected;
        use Modern::Perl;
    
        sub getConnection { 
            ...
        }
    }
    {   package ConnectedObject;
        use Modern::Perl;
        use parent 'Connected';
    
        use Class::Delegator 
            send => [ 'getVersion'
                    , 'obliterateAllLifeforms'
                    , ... 
                    ]
            to   => 'getConnection'
            ;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Trying to get the hang of using OOP in Perl. My problem is that
I wonder what's the pros/cons of using delegate vs OOP when implementing strategy design
I was wondering how well Perl would perform for OOP based programming. What are
I have decided to start coding using OOP and a PHP framework. I have
Instead of using common OOP, like Java and C# do with their base class
I've been tinkering with some code in a effort to understand OOP using c.
Currently I have something in lua that is like OOP using tables. TCharacterController =
I'm currently starting with Perl OOP using the Moose package. The compiler complains that
I'm using classic OOP code from Mozilla var myExtension = { init: function() {

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.