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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:27:17+00:00 2026-06-04T17:27:17+00:00

From perldoc perlobj (quoted in this excellent answer ): my $fred = Critter->find(Fred); $fred->display(Height,

  • 0

From perldoc perlobj (quoted in this excellent answer):

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

… the above code is mostly equivalent to:

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

What exactly is the difference, leaving aside error checking to make sure the first parameter is a blessed object or a valid class name? E.g. why is it mostly but not exactly the same?

  • 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-04T17:27:19+00:00Added an answer on June 4, 2026 at 5:27 pm

    Say Critter is a subclass that doesn’t define find or display—or both! The correspondence isn’t one-for-one because hardwired sub calls don’t perform method lookup, as the perlobj documentation explains.

    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.

    With a sub, you have to know exactly where it is statically, or your program will die. To call a method, you need only specify where to begin searching for it.

    For example:

    #! /usr/bin/env perl
    
    package Critter;
    sub new { bless {}, shift }
    sub display { ref($_[0]) . " display" }
    
    package SuperCritter;
    @SuperCritter::ISA = qw/ Critter /;
    
    package main;
    my $super = SuperCritter->new;
    
    # one of these things is not like the other
    warn $super->display;
    warn Critter::display($super);
    warn SuperCritter::display($super);
    

    Output:

    SuperCritter display at ./call-demo line 14.
    SuperCritter display at ./call-demo line 15.
    Undefined subroutine &SuperCritter::display called at ./call-demo line 16.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I copied this example from perldoc -f sort . I added the @old array
the following code snippet taken from http://perldoc.perl.org/perlrequick.html#Search-and-replace gives me Bareword found where operator expected
From viewing the source code that this code makes it looks like itemValue generate
From perldoc -f bless : bless REF,CLASSNAME This function tells the thingy referenced by
I find from reading perldoc perlvar, about a thousand lines in is help for
From this perldoc page , To capture a command's STDERR and STDOUT together: $output
From perldoc -f each we read: There is a single iterator for each hash,
From the question you can probably tell that I don't know much about code!
From observing source code for various Android applications (not written by me), I noticed
From the documentation of oracle : Domain Runtime MBean Server : This MBean server

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.