$class::SUPER as well as $instance::SUPER?

Discussion in 'Perl Misc' started by Matthew Braid, Aug 6, 2004.

  1. Hi all,

    Just a quick question - I just found out that this:

    package Bar;

    sub woo { print "WOO!\n" }

    package Foo;
    use base qw/Bar/;

    sub woo {
    my $class = shift;
    $class::SUPER->woo(); # EEK!
    print "WOO2!\n";
    }

    package main;
    Foo->woo();
    1;
    __END__

    does not work - the line marked with # EEK! causes perl to die with the message
    'Can't call method "woo" on an undefined value at ....'.

    I take it that you can't find a _class_'s super class via the ::SUPER construct
    (it obviously works for an instance of the class).

    Is there something else I can do to accomplish this?

    MB
    Matthew Braid, Aug 6, 2004
    #1
    1. Advertising

  2. Matthew Braid wrote:

    > Just a quick question - I just found out that this:

    ....
    > $class::SUPER->woo(); # EEK!

    ....
    > does not work


    It works if you write it correctly. ;-)

    $class->SUPER::woo();

    sherm--


    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Aug 6, 2004
    #2
    1. Advertising

  3. Sherm Pendley wrote:

    > Matthew Braid wrote:
    >
    >> Just a quick question - I just found out that this:

    >
    > ...
    >
    >> $class::SUPER->woo(); # EEK!

    >
    > ...
    >
    >> does not work

    >
    >
    > It works if you write it correctly. ;-)
    >
    > $class->SUPER::woo();
    >
    > sherm--
    >
    >


    D'oh! That's what I get for writing code on a friday afternoon. Sheesh.

    Thanks :)
    Matthew Braid, Aug 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,744
    Darryl Pierce
    Feb 24, 2005
  2. Fernando Rodriguez

    Getting the super class via the super() function

    Fernando Rodriguez, Nov 21, 2003, in forum: Python
    Replies:
    2
    Views:
    710
    Bob Willan
    Nov 22, 2003
  3. Sridhar R
    Replies:
    14
    Views:
    1,382
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Feb 10, 2004
  4. Martin P. Hellwig
    Replies:
    1
    Views:
    367
    Martin P. Hellwig
    Mar 26, 2010
  5. fi3nd
    Replies:
    0
    Views:
    373
    fi3nd
    Apr 8, 2010
Loading...

Share This Page