Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Global variables *plug*

by broquaint (Abbot)
on Jul 01, 2002 at 17:37 UTC ( [id://178618]=note: print w/replies, xml ) Need Help??


in reply to Re: Global variables
in thread Improper use of global variable? (was: Global variables)

And here's a perfect situation to take advantage of Sub::Lexical's ability to emulate nested subs ...
use Sub::Lexical; sub find_key_dupes { my $binary_tree=shift; my $key=shift; my @dupes; my sub get_dupes($) { my $node=shift; return unless $node; if ($node->{key} lt $key) { get_dupes($node->{right}); } else { push @dupes,$node if $node->{key} eq $key; get_dupes($node->{left}); } } get_dupes($binary_tree); return \@dupes; }
Thanks demerphq, I'll be using this as valid example code in future. <simpsons voice="Mr. Burns">ehhhxcellent</simpsons>.
HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found