NOTE: I'm using perl 5.00503 on Solaris 5.8 very unfortuantely.

I know I'm missing something really stupid easy, so at the risk of sounding like a complete moron, I'll ask anyways. That sort of thing doesn't intimidate me. Basically, I'm trying to do with Package variables what happens with subroutines. Its easier to explain in code:
package Obj; use strict; our $Name; sub new { my $proto = shift; my $class = ref $proto || $proto; my $self = bless {}, $class; return $self; } sub test { my $self = shift; print "$Name \n"; } package Test; use strict; our @ISA=("Obj"); $Name = 'Testing'; package main; my $t = new Test; $t->test;
As you probly already know this produces an error about $Name being undeclared. So I tried this:
#$Name = "Testing"; TO our $Name = "Testing";
Which results in printing nothing. So then I remember TheDamian's book, and the "SUPER::" package, so I figure if I _HAVE_ to I'll do this:
#$Name = "Testing"; TO $SUPER::Name = "Testing";
I get the same results as before. Nothing is printed. So I delve into perltoot, perltooc, perlbot, and perlobj which present similar but not exactly the same thing style examples. Confused and wondering if I've been dreaming for the past few years of perl development, I hardcore the package for a sanity check:
#$Name = "Testing"; TO $Obj::Name = "Testing";
This code actually works and produces the desired output. Leaving me completely Confused. Is "SUPER::" only for subroutine location? I want to abstract out the "Obj" class from the "Test" Class. Ideally, I'd like the the test() method in the the Obj class be able to use the current package's $Name. What is the best way to acheive this?

Update: My orignal code actually does what I want on perl 5.6.1 on my personal machine. Am I forced to kludge this to work with perl 5.00503?
-brad..

In reply to Package Variables in Inheritance by reyjrar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.