Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

RE: Re: Its not supposed to!

by BBQ (Curate)
on Apr 18, 2000 at 04:57 UTC ( [id://7895]=note: print w/replies, xml ) Need Help??


in reply to Re: Its not supposed to!
in thread Its not supposed to!

I *think* I get it...

What you're saying is that I could as well do this
foreach $leaf (glob("$startdir/*")) { if (-d $leaf) { $trash = GetDirs($leaf); push(@dirs,$leaf); } }
because it would still recurse, and it really doesn't matter what I'm assigning the return of the recursion (like $trash) because I'm pushing every $leaf to @dirs right after anyway? What really matters is the return of the 1st call and not the $trash.

Or was that totally off track?

BTW: You're explanations are always fun to read... Thanx!

Replies are listed 'Best First'.
RE: RE: Re: Its not supposed to!
by chromatic (Archbishop) on Apr 18, 2000 at 06:19 UTC
    You don't even need the assignment to $trash in there, as the function might as well be declared void (in C or C++, if you're familiar). What you're concerned about is the side-effect of the subroutine.

    I tried to come up with a better way to do that, without the global variable, but I think you've hit on the clearest method with that recursion.

    (BTW, there is an account for isotope on this machine, though not under that nickname. Thanks for the kind words.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-23 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found