[Israel.pm] OO in perl question

Issac Goldstand margol at beamartyr.net
Thu Nov 4 01:08:06 PST 2004

First of all, you can store "a" in the blessed variable that represents your 
If that's not possible, then you can store $Da::a, $Db::a ... $Dk::a. In 
class B, the get_a could do:
return eval ("$".ref($_[0])."::a");

That's untested, and I'm sure there's a neater way than using the icky eval, 
but it ought to do what you want...


----- Original Message ----- 
From: "Itamar Elem" <elem at compugen.co.il>
To: <perl at perl.org.il>
Sent: Thursday, November 04, 2004 10:51 AM
Subject: [Israel.pm] OO in perl question

> hi
> i have the following situation:
> packages D1,..,Dk which derived from package B in perl
> and var $a in each of the packages D1,..Dk, B
> and lets say single accessor name get_a defined in B only;
> is there clean way which get_a return the correct $a;
> for example:
> $c = new D2();
> print $c->get_a()
> will print the content of $a from D2;
> is there different sollution if $a is my var or global package var
> thanks itamar
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl

More information about the Perl mailing list