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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:41:35+00:00 2026-06-09T23:41:35+00:00

Note that UNIVERSAL::isa does not work for me in this case. I do not

  • 0

Note that UNIVERSAL::isa does not work for me in this case.
I do not want to walk up the inheritance tree as __PACKAGE__->isa('UNIVERSAL') does.

Here is an example:

  use 5.10.1;
  use strict;
  use warnings;
  use utf8;
  {
    package Parent;
    #How to do this more elegantly?
    sub inherits_from_parent {
      no strict 'refs';
      return (__PACKAGE__ eq @{"$_[0]\::ISA"}[0]);
    }
  }
  {
    package Child;  
    use parent -norequire, qw(Parent);
  }
  package main;

  say "Child directly inherits from Parent"
    if Child->inherits_from_parent;
  #not wat I want 
  say 'Child is universal:'.Child->isa('UNIVERSAL');

Is there a better way (without using no strict 'refs';) to detect the direct parent of a class?
Thanks.

  • 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-09T23:41:36+00:00Added an answer on June 9, 2026 at 11:41 pm

    I don’t think that there is anything wrong with looking at the @ISA array for the class, in fact, this is what Perl does and almost certainly what any diagnostic module would do. Remember that there is nothing evil about turning off parts of strict when you know why you are doing it, and this is one of those cases.

    To your actual question, a little Googling has yielded a few possibilities, of which Curtis Poe (Ovid)’s Class::Sniff may be the best example.

    I know that Data::Printer prints out the class hierarchy when you dump an object. Its output is meant for human readers, but you might be able to look at its code to see what it does. Again, I’m almost certain it does exactly what you do in your example!

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

Sidebar

Related Questions

Note that this function does not have a { and } body. Just a
(note that this question is not about CAS, it's about the May fail spuriously
Note that this relates to focus and blur events on a window, not on
Please note that this question is not about the mysql query per se, but
Please note that this question is not about the mysql query per se, but
Please note that although it sounds similar, this is not the common how to
Note that this is not about auto-completion or the excellent code formatter, Alt+Shift+F which
Note that I'm not actually doing anything with a database here, so ORM tools
Note that this question refers to the version running the app, not all versions
* Please note that this is not for a web based application, it's windows

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.