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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:29:09+00:00 2026-05-26T19:29:09+00:00

When executing the statement $obj->method(); , perldiag says that Perl needs to know what

  • 0

When executing the statement $obj->method();, perldiag says that Perl needs to know what package the method belongs to. That’s why it needs to be blessed:

Can’t call method “%s” on unblessed reference

(F) A method call must know in what package it’s supposed to run. It
ordinarily finds this out from the object reference you supply, but
you didn’t supply an object reference in this case. A reference isn’t
an object reference until it has been blessed. See
perlobj.

Because of this, it isn’t possible to do the following:

my $data = [
             [ 1, 2, 3 ],
             [ 4, 5, 6 ],
           ];

$data->process( @params );  # Can't call method "process" on unblessed reference

Then why does it work with a coderef?:

my $process = \&process;    # Same method as before
$data->$process( @params ); # Works fine now
  • 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-26T19:29:10+00:00Added an answer on May 26, 2026 at 7:29 pm
    $variable->method(@args)
    

    just invokes

    method($variable, @args)
    

    But in which package should Perl find the method subroutine? If $variable is a blessed reference, Perl will look for the subroutine in the package returned by ref $variable. If $variable is a string and the name of a package, Perl will look for the subroutine in that package name.

    In your second example, when you declare

    $process = \&process
    

    you have given Perl the reference to the code you want to invoke, so Perl knows to take the call

    $variable->$process(@args)
    

    and invoke

    $process->($variable, @args)
    

    or

    &process($variable, @args)
    

    It is only when $variable is an unblessed reference, and the method name can not be resolved into a code reference, that Perl cannot figure out what to do and punts.

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

Sidebar

Related Questions

I have a while statement that's executing correctly but it needs to be a
I have an SQL statement that I'm executing through OleDb, the statement is something
I am executing If statement based on some vales but Nunit executes all statements
I am executing this statement under while (($data=fgetcsv($this->fin,5000,;))!==FALSE) Now what I want in else
When attempting to understand how a SQL statement is executing, it is sometimes recommended
Why is this script executing the string in the if statement: #!/bin/bash FILES=* STRING=''
I'm running the following statement to see what queries are executing in sql server:
I'm having trouble with a line inside an if statement executing before the conditional
I have got a requirement that mysql database can only be accessed from localhost.
I am having issues executing a SQL statement from a stored proc having single

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.