Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: More Macro work...out to export a definition to next-outer level?

by perl-diddler (Hermit)
on Sep 30, 2010 at 12:13 UTC ( #862784=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://862784]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (15)
As of 2014-09-02 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (25 votes), past polls