in reply to Re^2: More Macro work...out to export a definition to next-outer level?
in thread More Macro work...out to export a definition to next-outer level?

That's lame! I edited the above, even previewed it, and resubmitted it with an inserted 'code' tag (it was missing one before the code, as you can see, it already had one after the code ;-/ ). But only the above version was stored and it seems I can't update it. Oh poo! Anyway, hopefully this version will stay with the code tag intact!
#!/usr/bin/perl -w #use strict; use feature ':5.10'; BEGIN { sub instance_vars { my $pck=caller; foreach(@_) { eval "sub ${pck}::$_ { my \$p = shift; \$p->{$_} = \$_[0] if \@_; \$p->{$_}; }" } } } package MyPackage; *instance_vars=\&main::instance_vars; { instance_vars( qw(one two three) ); sub new { my $package=shift; my $parms=$_[0]; my $this={}; foreach(%$parms) { $this->{$_}=$parms->{$_}; } bless $this, $package; } } package MyPackagetwo; { our @ISA = qw (MyPackage); } package main; my $p=new MyPackagetwo({three => 3,}); $p->two(2); printf "two=%d, three=%d\n",$p->two, $p->three;
  • Comment on Re^3: More Macro work...out to export a definition to next-outer level?
  • Download Code