Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
and then I realised I had to add another level so it was like this:for(1 .. 10){ for(a .. c){ #do something } }
and I started thinking, is it possible to write code in perl where you could recurse as many times as required? In other words, could you write a sub that would work like this:for( 1 .. 10 ){ for( a .. c ){ for( x .. z ){ #do something } } }
and if so how?do_my_recursion('1 .. 10'); # or do_my_recursion('1 .. 10','a .. c'); # or do_my_recursion('1 .. 10','a .. c','x .. y'); # and so on
I don't actually need the answer to this question in any way, I should say, I'm just wondering about it as a purely theoretical thing.
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Arbitrary Levels Of Recursion?
by ikegami (Patriarch) on Apr 01, 2005 at 02:10 UTC | |
by gam3 (Curate) on Apr 01, 2005 at 02:55 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by moot (Chaplain) on Apr 01, 2005 at 02:13 UTC | |
by Cody Pendant (Prior) on Apr 01, 2005 at 02:30 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by Random_Walk (Prior) on Apr 01, 2005 at 13:11 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by Madams (Pilgrim) on Apr 04, 2005 at 04:00 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by TedPride (Priest) on Apr 01, 2005 at 07:48 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by tlm (Prior) on Apr 01, 2005 at 02:50 UTC | |
|
Re: Arbitrary Levels Of Recursion?
by DrHyde (Prior) on Apr 01, 2005 at 11:47 UTC | |
by perlfan (Parson) on Apr 01, 2005 at 20:08 UTC |