Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

ehdonhon's scratchpad

by ehdonhon (Curate)
on Jun 04, 2004 at 17:59 UTC ( #361020=scratchpad: print w/replies, xml ) Need Help??

Here is some (very slightly modified) code directly from the NEXT module perldoc. Note I commented out sub foo in package E:

package A; sub foo { print "called A::foo\n"; shift->NEXT::UNSEEN::foo() } package B; sub foo { print "called B::foo\n"; shift->NEXT::UNSEEN::foo() } package C; use vars qw( @ISA ); @ISA = qw( A ); sub foo { print "called C::foo\n"; shift->NEXT::UNSEEN::foo() } package D; use vars qw( @ISA ); @ISA = qw(A B); sub foo { print "called D::foo\n"; shift->NEXT::UNSEEN::foo() } package E; use vars qw( @ISA ); @ISA = qw(C D); #sub foo { print "called E::foo\n"; shift->NEXT::UNSEEN::foo() } package ::; E->foo();

And here is its output:

called C::foo
called A::foo
called D::foo
called B::foo

Now, here is my code that does almost the exact same thing:

#!/usr/local/bin/perl use NEXT; use strict; package ROOT; sub traverse { print __PACKAGE__, "\n"; } package LEFT_CHILD; #use base 'ROOT'; use vars qw( @ISA ); @ISA = qw( ROOT ); sub traverse { my $package = shift; print __PACKAGE__, "\n"; $package->NEXT::UNSEEN::traverse(); } package RIGHT_CHILD; #use base 'ROOT'; use vars qw( @ISA ); @ISA = qw( ROOT ); sub traverse { my $package = shift; print __PACKAGE__, "\n"; $package->NEXT::UNSEEN::traverse(); } package GRANDCHILD; #use base 'LEFT_CHILD'; #use base 'RIGHT_CHILD'; use vars qw( @ISA ); @ISA = qw( LEFT_CHILD RIGHT_CHILD ); package ::; GRANDCHILD->traverse();

Here is the output:

LEFT_CHILD
ROOT
<demerphq> Incidentally to those who say XP means nothing: The abscence of XP doesnt mean you arent a good programmer, but the prescence of it doessuggest hat you arent a crap programmer. my $0.02. :-)

Nodes relating to XP:

(humor) The first rule of The XP club is...
One Point to Saint hood
The meaning of life, the universe and node reputation
Experience this!
Experience for nodes (to display or not)
Too much positive votes on questions (Seekers of Perl Wisdom)
PM's XP system, fair or not?
Why your product is sold?
XP for CB
When to --
Sainthood via Seniority Simulation
Re: Re: Re: reading lines
Reputation for anonymous monks
Voting - single Vs. multiple nodes
I am "Big XP Baby" button
Voting etiquette
Possible changes to Voting/XP
Why down vote is soo easy?!
If (the PM XP system) ain't broke, don't fix it
Encouraging comments for downvotes
Experience points counter issue?
Fastest Rising Monks - Revisited
Huge ammounts of incoming EXP
Distribution of Levels and Writeups
No more XP for voting!
Node Rep - A newbies viewpoint
(contest) Help analyze PM reputation statistics
XP, page ranking, sponsored links and the fortune of PM
XP, page ranking, sponsored links and the fortune of PM
Why upvote a node?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2020-02-19 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (80 votes). Check out past polls.

    Notices?