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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:05:18+00:00 2026-05-23T11:05:18+00:00

Should instance methods in Perl call each other like this: package BlaBla; sub foo

  • 0

Should instance methods in Perl call each other like this:

package BlaBla;

sub foo {
    my($self) = @_;
    #do something awesome;
}

sub bar {
    my($self) = @_;
    foo();
}

Or like this:

package BlaBla;

sub foo {
    my($self) = @_;
    #do something awesome
}

sub bar {
    my($self) = @_;
    $self->foo();
}

Thank you all for your time.

  • 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-23T11:05:18+00:00Added an answer on May 23, 2026 at 11:05 am

    Yes, you should include $self – if you don’t, polymorphism won’t work because each method will look for all calls in its own package, even if they’re overridden in a subclass. Worse, if the referenced method is inherited from a parent and not overridden in the current subclass, the program will die because it doesn’t exist in that package. And that’s even if you do remember to try to fake out Perl’s OO mechanism by passing $self as the first parameter.

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

Sidebar

Related Questions

Given the code: new Thread(new BackgroundWorker()).start(); Intuitively it feels like the BackgroundWorker instance should
Suppose I have a class with a string instance attribute. Should I initialize this
What is the difference between class and instance methods in Objective-C and when should
I have a class that is something like the following: public class Foo {
I see everywhere examples that super-class methods should be called by: super(SuperClass, instance).method(args) Is
The this keyword is optional when accessing instance fields, properties, and methods in languages
I have a class CommonTableModel that has several instance methods and each operate on
As per my understanding we should go for instance methods only when they are
I need to mock a GrailsControllerClass interface. Instance should have a static variable defined.
Should Singleton objects that don't use instance/reference counters be considered memory leaks in C++?

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.