Phoenix.pm: More symbol table weirdness
Douglas E. Miles
doug.miles at ns2.phoenix.bowne.com
Thu Feb 10 12:36:59 CST 2000
Thanks alot Tim! I bow to your superior symbol table knowledge. I'm
not worthy! :)
Actually that was the first approach that I tried. I just couldn't get
the derefrencing right. :( I was actually hoping that someone might
show me how to do this. I guess I need to dig deeper into the symbol
table. I'll try this too and let you know. Thank!
Beaves at aol.com wrote:
>
> In a message dated 2/10/00 10:31:20 AM US Mountain Standard Time,
> doug.miles at ns2.phoenix.bowne.com writes:
>
> << # Make XML_ObjTree::* inherit from XML_ObjTree.
> my $package_declaration = <<"EOD";
> package XML_ObjTree::$package;
> \@ISA = ('XML_ObjTree');
> EOD
>
> eval $package_declaration;
> >>
>
> I think I mentioned this in a previous post, but this eval is unecessary.
> You just have to declare at least one variable in the package and that
> package springs into existence. And, it doesn't matter what the current
> package is. So the above code could be reduced to one line with no eval.
>
> # package is the current package.
> @{"XML_ObjTree::$package\::ISA"} = ('XML_ObjTree');
>
> and the package XML_ObjTree::$package will be created. Note, you have to
> escape the first colon before the 'ISA'. If you don't, then you'll be
> interpolating the variable $ISA in the package 'package' which is not what
> you want in this case.
>
> If someone doesn't quite get this stuff, post your questions. Since I started
> understanding a bit about Perl packages and symbol tables, I've found the
> above technique and stuff similar to it to be VERY useful. I think it should
> be in everyone's Bag o' Tricks.
>
> Tim
--
Socrates is a man. All men are mortal. Therefore, all mortals are
Socrates.
More information about the Phoenix-pm
mailing list