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

  • Home
  • SEARCH
  • 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 69513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:35:08+00:00 2026-05-10T19:35:08+00:00

According to this http://perldoc.perl.org/UNIVERSAL.html I shouldn’t use UNIVERSAL::isa() and should instead use $obj->isa() or

  • 0

According to this

http://perldoc.perl.org/UNIVERSAL.html

I shouldn’t use UNIVERSAL::isa() and should instead use $obj->isa() or CLASS->isa().

This means that to find out if something is a reference in the first place and then is reference to this class I have to do

eval { $poss->isa('Class') } 

and check $@ and all that gumph, or else

use Scalar::Util 'blessed'; blessed $ref && $ref->isa($class); 

My question is why? What’s wrong with UNIVERSAL::isa called like that? It’s much cleaner for things like:

my $self = shift if UNIVERSAL::isa($_[0], __PACKAGE__) 

To see whether this function is being called on the object or not. And is there a nice clean alternative that doesn’t get cumbersome with ampersands and potentially long lines?

  • 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. 2026-05-10T19:35:09+00:00Added an answer on May 10, 2026 at 7:35 pm

    The primary problem is that if you call UNIVERSAL::isa directly, you are bypassing any classes that have overloaded isa. If those classes rely on the overloaded behavior (which they probably do or else they would not have overridden it), then this is a problem. If you invoke isa directly on your blessed object, then the correct isa method will be called in either case (overloaded if it exists, UNIVERSAL:: if not).

    The second problem is that UNIVERSAL::isa will only perform the test you want on a blessed reference just like every other use of isa. It has different behavior for non-blessed references and simple scalars. So your example that doesn’t check whether $ref is blessed is not doing the right thing, you’re ignoring an error condition and using UNIVERSAL‘s alternate behavior. In certain circumstances this can cause subtle errors (for example, if your variable contains the name of a class).

    Consider:

    use CGI;  my $a = CGI->new();  my $b = 'CGI';  print UNIVERSAL::isa($a,'CGI');  # prints 1, $a is a CGI object. print UNIVERSAL::isa($b,'CGI');  # Also prints 1!! Uh-oh!! 

    So, in summary, don’t use UNIVERSAL::isa… Do the extra error check and invoke isa on your object directly.

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

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You'll get that error if your post-commit is failing. Try… May 11, 2026 at 3:19 pm
  • added an answer So you have a library which references WindowsForms, but doesn't… May 11, 2026 at 3:19 pm
  • added an answer Ack! Forget that, just found the answer here for anyone… May 11, 2026 at 3:19 pm

Related Questions

According to this http://perldoc.perl.org/UNIVERSAL.html I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i
According to this: http://www.codeplex.com/IronPython/Wiki/View.aspx?title=IP20VsCPy25Perf&referringTitle=IronPython%20Performance IronPython (Python for .Net) is faster than regular Python (cPython)
According to this http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html article, I defnitely should. Quote Gentle, yet insistent executive summary:
At the moment we are using MAPI to send a plain text email from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.