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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:28:52+00:00 2026-06-04T20:28:52+00:00

In terms of Perl OO, what exactly does -> do? For example I make

  • 0

In terms of Perl OO, what exactly does -> do?

For example I make a call main:

$result = a::b->mymethod( );

In the package where I define mymethod(), I use the following:

    my( $class ) = @_;

In main, I clearly don’t pass any arguments to mymethod(), so where is the $class argument coming from? Has anyone got a good explanation for this or a document that explains this?

  • 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-06-04T20:28:53+00:00Added an answer on June 4, 2026 at 8:28 pm

    The “Method Invocation” section of the perlobj documentation explains. The added emphasis is mine.

    Method Invocation

    For various historical and other reasons, Perl offers two equivalent ways to write a method call. The simpler and more common way is to use the arrow notation:

    my $fred = Critter->find("Fred");
    $fred->display("Height", "Weight");
    

    You should already be familiar with the use of the -> operator with references. In fact, since $fred above is a reference to an object, you could think of the method call as just another form of dereferencing.

    Whatever is on the left side of the arrow, whether a reference or a class name, is passed to the method subroutine as its first argument. So the above code is mostly equivalent to:

    my $fred = Critter::find("Critter", "Fred");
    Critter::display($fred, "Height", "Weight");
    

    How does Perl know which package the subroutine is in? By looking at the left side of the arrow, which must be either a package name or a reference to an object, i.e., something that has been blessed to a package. Either way, that’s the package where Perl starts looking. If that package has no subroutine with that name, Perl starts looking for it in any base classes of that package, and so on.

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

Sidebar

Related Questions

I'm trying to use quotemeta in Perl. The following is the code with the
The Term::Size-module jumbles up the encoding. How can I fix this? #!/usr/bin/env perl use
In terms of performance and efficiency, is it better to use lots of small
In terms of SQL terminology, does HEAP stands for a table that has Non-Clustered
I want a progress indicator that takes the output of a Perl system('make') and
I have a file with one phrase/terms each line which i read to perl
Does anyone know where online copies of the old The Perl Journal articles can
#!/usr/bin/env perl use warnings; use 5.12.0; use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new(
#!/usr/bin/perl -w use strict; sub fib { my($num) = @_; #give $num to input
In Perl there is a very handy module, Term::VT102, which allows you to create

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.